Re: [android-developers] Re: Rounding Numbers

2011-04-13 Thread Daniel Drozdzewski
Zsolt, I hear what you are saying and generally agree, however we have been using calculations 'plagued by rounding errors' for centuries and our bridges are not collapsing. Such is a nature of a calculator, even scientific one. there is a reason, why Math Java API or even Apache Commons Maths us

[android-developers] Re: Rounding Numbers

2011-04-13 Thread Zsolt Vasvari
The OP is talking about a calculator app. He should absolutely be using BigDecimals, which take care of rounding issues. I'd certainly wouldn't want to download a calculator app that's plauged by rounding errors. > All physical scientific calculators use floating points. There are > places, wher

[android-developers] Re: Rounding Numbers

2011-04-13 Thread Zsolt Vasvari
You should not use double/float when dealing with exact numbers, such as a calculator. You need to use BigDecimal. On Apr 13, 2:18 am, Gabriel wrote: > I resolved it using: > >                 double result = //old result// >                 *100 > >                 double newresult =(Math.round

Re: [android-developers] Re: Rounding Numbers

2011-04-13 Thread Daniel Drozdzewski
On Wed, Apr 13, 2011 at 9:29 AM, Zsolt Vasvari wrote: > You should not use double/float when dealing with exact numbers, such > as a calculator.  You need to use BigDecimal. All physical scientific calculators use floating points. There are places, where you cannot use anything else than BigDecim

[android-developers] Re: Rounding Numbers

2011-04-12 Thread Gabriel
I resolved it using: double result = //old result// *100 double newresult =(Math.round(result)); double finalresult = (newresult) / 100; On 12 abr, 14:29, Harsh J wrote: > There is a DecimalFormat class generally available in Java

[android-developers] Re: Rounding Numbers

2011-04-12 Thread Gabriel
Sorry, this was not clear to me. I didn't get both parts On 12 abr, 14:18, Kostya Vasilyev wrote: > 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