Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2004

Tip: Looking for answers? Try searching our database.

Getting the int remainder

Thread view: 
Mark K - 06 Dec 2004 19:22 GMT
How do I get the integer remainder from a double?

i.e. dVariable = 13.4545;

I want to return the integer part (13)
Eric Sosman - 06 Dec 2004 19:33 GMT
> How do I get the integer remainder from a double?
>
> i.e. dVariable = 13.4545;
>
> I want to return the integer part (13)

    int thirteen = (int)dVariable;

See also the ceil(), floor(), and rint() methods of
java.lang.Math.

Signature

Eric.Sosman@sun.com

Mark K - 07 Dec 2004 18:32 GMT
i figured that out finally.  Thanks
casting.. what a concept.. haha

> > How do I get the integer remainder from a double?
> >
[quoted text clipped - 6 lines]
> See also the ceil(), floor(), and rint() methods of
> java.lang.Math.
Grant Wagner - 07 Dec 2004 18:44 GMT
> How do I get the integer remainder from a double?
>
> i.e. dVariable = 13.4545;
>
> I want to return the integer part (13)

double dValue = 13.4545;
int iValue = (int) dValue;

--
Grant Wagner <gwagner@agricoreunited.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.