Re: [android-developers] Rounding Numbers

2011-04-13 Thread Daniel Drozdzewski
On Tue, Apr 12, 2011 at 5:55 PM, Gabriel wrote: > I have a calculator app and I want to round the number after comma. > > Like, if the result is 15,3 I want to keep it on 15,33 or 15,3 > > Does any know how to do that? > > Thanks, I really appreciate the help Do you simply want to format su

Re: [android-developers] Rounding Numbers

2011-04-12 Thread Harsh J
There is a DecimalFormat class generally available in Java. It can handle the precision amongst other things (like separator character based on locale, currency unit based on locale, etc.) while string-representing doubles. Here's the full API: http://download.oracle.com/javase/6/docs/api/java/tex

Re: [android-developers] Rounding Numbers

2011-04-12 Thread Kostya Vasilyev
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

[android-developers] Rounding Numbers

2011-04-12 Thread Gabriel
I have a calculator app and I want to round the number after comma. Like, if the result is 15,3 I want to keep it on 15,33 or 15,3 Does any know how to do that? Thanks, I really appreciate the help -- You received this message because you are subscribed to the Google Groups "Android Develo