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

Username:   Password: 
 RegisterRegister   
 Decimal Rounding
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MysticVegeta




PostPosted: Fri Nov 25, 2005 7:29 pm   Post subject: Decimal Rounding

Say I want to round to the second decimal space, Is there a function for it or do I have to create on manually.
Turing:
frealstr(x : real, y : int, z : int)
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Fri Nov 25, 2005 7:31 pm   Post subject: (No subject)

Java 1.5

Java:
String.format("%.2f", someFloatNumber)
MysticVegeta




PostPosted: Sat Nov 26, 2005 11:29 am   Post subject: (No subject)

what do i need to import to make it work?
MysticVegeta




PostPosted: Sat Nov 26, 2005 1:14 pm   Post subject: (No subject)

Sorry The edit button is not working for me.
I am using java 1.4.2 (ready), isnt there a premade function in 1.4?
rizzix




PostPosted: Sat Nov 26, 2005 1:39 pm   Post subject: (No subject)

pre 1.5 u need to do this:
Java:
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
String str_double = df.format(my_double);
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  [ 5 Posts ]
Jump to:   


Style:  
Search: