Author mark.dickinson
Recipients Serge Anuchin, mark.dickinson, pitrou, r.david.murray, rhettinger, serhiy.storchaka, skrah, steven.daprano, tim.peters, vstinner
Date 2018-06-25.19:45:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> a couple lines of inline assembler could be added at Python startup to
> set the Pentium's FPU "precision control" bits to "round to 53 bits" mode

On second thoughts, I don't think this will work; or at least, not easily. The libm on such a platform may expect the FPU to be in 64-bit precision mode. So we'd potentially need to switch the precision before calling any math library function and then switch it back again afterwards. And then there may be 3rd party libraries that need the same treatment.

On the existence of platforms with double rounding, last time I checked, 32-bit Linux was the most obvious offender on Intel hardware. Windows used to use the x87 but set the precision to 53 bits, and I think newer versions may well use SSE2 in preference to x87. macOS has used SSE2 for a good number of releases now.

And indeed, I just tested Python 3.5.2 on Ubuntu 16.04.4 LTS 32-bit (running in a VM on a not-too-ancient MacBook Pro), and it exhibits double rounding:

>>> (1e16 + 2.9999).hex()
>>> (1/2731).hex()
>>> 1/(1 - 2**-53)

Expected results without double rounding:

>>> (1e16 + 2.9999).hex()
>>> (1/2731).hex()
>>> 1/(1 - 2**-53)
Date User Action Args
2018-06-25 19:45:22mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, pitrou, vstinner, steven.daprano, r.david.murray, skrah, serhiy.storchaka, Serge Anuchin
2018-06-25 19:45:22mark.dickinsonsetmessageid: <>
2018-06-25 19:45:22mark.dickinsonlinkissue24567 messages
2018-06-25 19:45:22mark.dickinsoncreate