You could use String.format() of Formatter() with a ".2f" type format
(this one means: two digits in the fractional part).
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#dndec
You could also multiply the number by 100, or 10, as needed, convert it
to an integer thus removing the unneeded fractional part, and then
divide back by the scaling factor (100 or 10 or whatever).
-- Kostya
12.04.2011 20:55, Gabriel пишет:
I have a calculator app and I want to round the number after comma.
Like, if the result is 15,33333 I want to keep it on 15,33 or 15,3
Does any know how to do that?
Thanks, I really appreciate the help
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en