On Mar 3, 2008, at 7:25 AM, Mike Cowlishaw wrote:

"Igor Bukanov" <[EMAIL PROTECTED]> wrote on 03/03/2008 14:39:32:

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.

ES3 added Number.prototype.toFixed and a few others. They are not enough as Mike says, and practically no one knows to use them.

That's unfortunately not true. Not only is the required toFixed number unpredictable in many applications, but it may give the wrong answer even
when known.  See item 2 at:

  http://www2.hursley.ibm.com/decimal/decifaq1.html#inexact

(This particular problem is systematic, and it adds up to around $2M for a
medium-sized telco.  That misplaced $2M is cheating either the
shareholders, the customers, or the taxman. None of those options look
good in a newspaper report :-).)

Office Space ;-)

/be
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to