[issue24546] sequence index bug in random.choice

Steven D'Aprano report at bugs.python.org
Fri Jul 3 01:58:55 CEST 2015


Steven D'Aprano added the comment:

On Thu, Jul 02, 2015 at 05:35:53PM +0000, Tim Peters wrote:
> Steven, there's something wrong with the arithmetic on your machine, 
> but I can't guess what from here (perhaps you have a non-standard 
> rounding mode enabled, perhaps your CPU is broken, ...).

It's not just me. Others have confirmed the same behaviour, but only 
on 32-bit Linux:

https://mail.python.org/pipermail/python-list/2015-July/693481.html

Thread begins here:
https://mail.python.org/pipermail/python-list/2015-July/693457.html

> For a start, is it the multiplication that's broken on your machine, or the int() part?

Looks like multiplication:

>>> x = 1.-2.**-53
>>> assert x.hex() == '0x1.fffffffffffffp-1'
>>> assert (2049.0).hex() == '0x1.0020000000000p+11'
>>> (x*2049.0).hex()  # Should be '0x1.001ffffffffffp+11'
'0x1.0020000000000p+11'

I'd like to see what result the OP gets if he runs this. Serge is using 
Linux, but if I'm reading it right, it looks like a 64-bit Linux.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24546>
_______________________________________


More information about the Python-bugs-list mailing list