Tim Peters added the comment:

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.

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1580>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to