Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #141739
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: A final word on casting. |
| Date | 2019-03-06 09:33 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <86k1hbucvh.fsf@mailhub.linuxsc.com> (permalink) |
| References | (16 earlier) <tUsXD.1964$gy2.1241@fx21.am4> <3pAXD.199851$e%3.151775@fx42.iad> <q0oj0b$khc$1@dont-email.me> <86mumjau3t.fsf@mailhub.linuxsc.com> <q58l4p$q2g$1@dont-email.me> |
James Kuyper <jameskuyper@alumni.caltech.edu> writes: > On 2/26/19 08:41, James Kuyper wrote: > ... > >> Thinking about it some more in response to your question, I suspect that >> a number slightly less than 1.0 might require slightly more significant >> digits than one slightly higher than 1.0. However, I don't have time to >> confirm that right now. > > I was on the right track, I just had to go down one order of magnitude. > The following are a consecutive pair of exactly representable double values: > > 0.100000000000000005551115123125782702118158340454101562500 == > 0x1.999999999999ap-4 > 0.100000000000000019428902930940239457413554191589355468750 > == 0x1.999999999999bp-4 > > The value exactly half way between them is: > 0.100000000000000012490009027033011079765856266021728515625 > == 0x1.999999999999a8p-4 > > Therefore, > 0.100000000000000012490009027033011079765856266021728515624 should round > to 0x1.999999999999ap-4, while > 0.100000000000000012490009027033011079765856266021728515626 should round > to 0x1.999999999999bp-4 > > Therefore, an implementation needs to read 57 significant digits before > it can determine which way to round either of those constants. For a > constant starting with > "0.100000000000000012490009027033011079765856266021728515625", it can > switch over to testing whether any of the subsequent digits is non-0, > but only after reading the first 57 significant digits. The number 2**300, which is 2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376 is exactly reprsentable. The next representable number is 2**300 + 2**248, so halfway between those is 2**300 + 2**247, which is 2037035976334486312424869980042572347713548488759506276554079249433607939328930471638728704 This gets us up to 91 digits. Can we do better?
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: A final word on casting. Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-02-25 23:26 -0800
Re: A final word on casting. "I Set My Girlfriend's Pantyhose on Fire" <cdalten@gmail.com> - 2019-02-26 03:12 -0800
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-02-26 05:41 -0800
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-02-26 19:00 -0800
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-02-27 06:37 -0800
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-02-28 07:45 -0500
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-02-28 08:20 -0500
Re: A final word on casting. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-02-28 15:16 +0000
Re: A final word on casting. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-01 01:16 +0000
Re: A final word on casting. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-02 01:10 +0000
Re: A final word on casting. Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-03-06 08:36 -0800
Re: A final word on casting. Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-03-06 09:04 -0800
Re: A final word on casting. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-21 11:19 +0000
Re: A final word on casting. Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-03-06 09:33 -0800
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-06 11:19 -0800
Re: A final word on casting. Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-03-23 10:49 -0700
Re: A final word on casting. James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-25 12:06 -0700
csiph-web