Adobe position paper on the ECMAScript 4 proposal space -- decimal

Igor Bukanov igor at
Mon Mar 3 06:39:32 PST 2008

On 27/02/2008, Brendan Eich <brendan at> wrote:
> I agree with what Lars wrote, except here I think the value of a
>  hypothetical (possibly mythical) "big red switch" is understated.
>The common problem is that you can't do "dollars
>  and cents" or "pounds and pennies" arithmetic and get the "right
>  answer":
>  js> 74.96-39.96
>  34.99999999999999

The problem here is not the binary float arithmetics but rather the
conversion of numbers into strings. If a global switch would exist
that would make a default toString conversion to use  a particular
version of toFixed, the problem would disappear for most user cases.

Moreover, decimal floats does not help much when calculating a VAT or
similar taxes. In many countries that requires explicit rounding to
cents, øre etc. of the final result with a particular minimal
precision in the intermediate calculations. Such requirements can be
meet both with decimal and binary floats.

For example, in Norway shops almost always show a price that includes
VAT. Typically the prices are round numbers or in those x9(9) formats.
Then the price excluding VAT is calculated using devisions and
included into the receipt using toFixed(2). Thus with either decimal
or binary floats the rounding is inevitable.

Regards, Igor

More information about the Es4-discuss mailing list