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
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
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
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
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
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
6 matches
Mail list logo