Zeroclickinfo-goodies: Calculator: wrong answer to pretty basic multiplication

Created on 10 Sep 2018  路  3Comments  路  Source: duckduckgo/zeroclickinfo-goodies

47.77 * 80000 is evaluated to 3821600.0000000005 which is not correct


IA Page: http://duck.co/ia/view/calculator
Maintainer: @pjhampton

All 3 comments

Answer is as-correct-as-possible from a double-precision 64-bit format IEEE 754-2008 (ECMAScript default for Number) point of view.

One of the numbers given doesn't have a exact representation as a double-precision number, so it is truncated (47.77).

To get correct results in the decimal representation, would require integration of either arbitrary-precision arithmetic or Decimal Floating Points (DEC64), that can represent such numbers without truncation.

Neither a trivial task, and each comes with several tradeoffs.

True, but a calculator that gives wrong answers is a pretty bad calculator. IMO it'd be better to remove the calculator rather than having it be unreliable. This is not an advanced calculation.

Any calculator by your definition gives wrong answers, because by definition in any radix, there's numbers that can't be represented correctly without infinite digits and will end up rounded. If the user enters such numbers it will "give wrong answers".

The difference, however, is that in most simple calculators _you can't notice the answer is wrong_.

I believe that, as a human being, noticing the anwser is wrong and checking _significant figures_ is more important that hiding the fact the result is wrong.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mintsoft picture mintsoft  路  5Comments

jonathancross picture jonathancross  路  5Comments

zappe picture zappe  路  5Comments

fzzr- picture fzzr-  路  5Comments

echamudi picture echamudi  路  5Comments