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: IEEE 754 Date: Fri, 29 Aug 2014 23:27:24 +0100 Organization: A noiseless patient Spider Lines: 45 Message-ID: <87mwanc4oj.fsf@bsb.me.uk> References: <87fvgh1qu9.fsf@bsb.me.uk> <87sikgzz71.fsf@bsb.me.uk> <3souv99slp2vt6nktr48gadd2e4r8th8o4@4ax.com> <871ts0md0v.fsf@bsb.me.uk> <87mwangjzy.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="3365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++Gq/aV6PZg49ShrjY0L6A3Z4r4VGgNvc=" Cancel-Lock: sha1:XByn68Z1IlMvwa2Jc3+yoYuYKi8= sha1:fw4xf3+jJCK9k+m+3YX45de169c= X-BSB-Auth: 1.40c72601252a41e0ba35.20140829232724BST.87mwanc4oj.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:25785 "Christoph M. Becker" writes: > Ben Bacarisse wrote: > >> Gene Wirchenko writes: >> >>> Yes. The value closest to 123.45 can be represented exactly. >> >> Sure. To be specific, for IEEE 754 double, it's 7B.733333333334 in hex. >> Using enough decimal digits to see what happening, that's about >> >> 123.45000000000000284217... > > According to John's fine IEEE 754 double format calculator[1] that is > correct. The hexadecimal representation is 405edccccccccccd, by the > way. Sure, but that's the bit representation of the double. If I've got it right, 7B.733333333334 is the number in plain base 16 which might be helpful in calculators that can do hex. However, I can see that it might have helped to show the bit representation of these: >> The three candidates are centred >> on 12345: >> >> 12344.999999999998181011... > > Correct. Hexadecimal representation: 40c81c7fffffffff > >> 12345.000000000000000000... > > Correct. Hexadecimal representation: 40c81c8000000000 > >> 12345.000000000001818989... > > Correct. Hexadecimal representation: 40c81c8000000001 > >> and 12345.0 is the closest. ...as it might have made what's going on clearer. -- Ben.