On 27/02/2008, Brendan Eich <[EMAIL PROTECTED]> 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
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to