Message58966
| Author | tim.peters |
|---|---|
| Recipients | christian.heimes, gvanrossum, nascheme, noam, rhettinger, skip.montanaro, tim.peters |
| Date | 2007-12-23.01:58:11 |
| SpamBayes Score | 0.0008925179 |
| Marked as misclassified | No |
| Message-id | <1198375094.33.0.741888676877.issue1580@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
If someone has a more recent version of MS's compiler, I'd be interested
to know what this does:
inc = 2.0**-43
base = 1024.0
xs = ([base + i*inc for i in range(-4, 0)] +
[base] +
[base + 2*i*inc for i in (1, 2)])
print xs
print ["%.16g" % x for x in xs]
That creates 7 distinct doubles all of which map to "1024" when
correctly rounded to 16 significant digits. And that's what the Cygwin
Python 2.5.1 (which presumably uses David Gay's correct-rounding
conversion routines from glibc) displays for the last line:
['1024', '1024', '1024', '1024', '1024', '1024', '1024']
The released Windows Python 2.5.1 displays this instead:
['1024', '1024', '1024', '1024', '1024', '1024', '1024.000000000001']
That's a pretty gross rounding error, since the exact value of the last
element is
1024.00000000000045474735088646411895751953125
and so the 16'th digit should indeed not round up to 1. It's a "pretty
gross" error because the rounded-off part isn't particularly close to a
half unit in the last (16'th) place. |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2007-12-23 01:58:15 | tim.peters | set | spambayes_score: 0.000892518 -> 0.0008925179 recipients: + tim.peters, gvanrossum, skip.montanaro, nascheme, rhettinger, christian.heimes, noam |
| 2007-12-23 01:58:14 | tim.peters | set | spambayes_score: 0.000892518 -> 0.000892518 messageid: <1198375094.33.0.741888676877.issue1580@psf.upfronthosting.co.za> |
| 2007-12-23 01:58:14 | tim.peters | link | issue1580 messages |
| 2007-12-23 01:58:12 | tim.peters | create | |