Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to round a float or double to 2 decimal places?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
illzidaneyou




PostPosted: Tue Jan 12, 2010 6:34 pm   Post subject: How to round a float or double to 2 decimal places?

What is the code for rounding a float or double to 2 decimal places?

The only rounding code I know is Math.round() but this only rounds to the nearest 0.5

Please let there be a code!

Any help is appreciated.
Sponsor
Sponsor
Sponsor
sponsor
jbking




PostPosted: Tue Jan 12, 2010 6:55 pm   Post subject: Re: How to round a float or double to 2 decimal places?

Sun's forums has a thread about this already.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: