Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: IE and IEE 754 Date: Sun, 31 Aug 2014 01:04:19 +0100 Organization: A noiseless patient Spider Lines: 44 Sender: benbacarisse@dsl-217-155-82-182.zen.co.uk Message-ID: <8761h9le2k.fsf@bsb.me.uk> References: <87fvgh1qu9.fsf@bsb.me.uk> <87sikgzz71.fsf@bsb.me.uk> <3souv99slp2vt6nktr48gadd2e4r8th8o4@4ax.com> <871ts0md0v.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="11964"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cxKjj353w8QXPP9zRI9k7SiRu9UlhDsA=" Cancel-Lock: sha1:BFWXtucJefnYoEF2sgZBVJHYoMg= sha1:NZAV1f1HJkhb6z5GZH6wRbzlrlk= X-BSB-Auth: 1.c73a75b0d51e02ae6e63.20140831010419BST.8761h9le2k.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:25796 Dr J R Stockton writes: > In comp.lang.javascript message <871ts0md0v.fsf@bsb.me.uk>, Fri, 29 Aug > 2014 00:04:48, Ben Bacarisse posted: > >>Gene Wirchenko writes: >> >>> On Thu, 28 Aug 2014 11:27:30 +0100, Ben Bacarisse >>> wrote: >>> >>> [snip] >>> >>>>I think it must. The ECMAScript specification imports IEEE 754's strict >>>>rounding and representation rules. The IEEE FP value closest to 123.45, >>>>when multiplies by 100 must yield 12345 according to those rules. >>> >>> Why? What if the value that you have (and want) happens to be >>> the value closest to 123.45? When you multiply that value by 100, >>> wouldn't you want 100 times the value instead of 12345? >> >>Yes, but you won't get it. You'll get the nearest floating point >>number, which is 12345. Am I missing your point? > > With FF31, or IE8, or Opera 12.17, or Chrome 36.0, in WinXP sp3, FWIW, > try > > S = "" > for (J=1 ; J<111 ; J+=2) S += "\n" + J + "\t" +(1/J)*J > alert(S) > > And, in FF31 and Chrome 37.0, > (123.45/100)*100 - 123.45 -> -1.4210854715202004e-14 > > Two nominally-inverse arithmetic operations on IEEE Doubles do not > always yield the exact input. Of course not (I hope I never suggested otherwise). I am happy to see that the result you report is the one expected from IEEE 745's rules, so I am not surprised that it's what you get in a wide range of browsers. (In fact those that did not give this result are the ones I'd won't to know about.) -- Ben.