Formating fraction part of float data type variable
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, May 10, 2003 04:24 AM

when i mutiply a float datat type value with a integer type value like.
ex: 34.66*3=103.9899 value as result.
But i want only two digits in fractional part.
what to do?

Re: Formating fraction part of float data type variable

Posted By:   Bahman_Barzideh  
Posted On:   Saturday, May 10, 2003 09:53 AM

I am assuming you are talking about # of significant
decimal digits only when you convert the float to a String (e.g. when printing it). If so you can try the DecimalFormat class. Something like:

DecimalFormat format = new DecimalFormat ("###,##0.00");
String x = format.format (floatValue);
About | Sitemap | Contact