Author mark.dickinson
Recipients benjamin.peterson, haypo, mark.dickinson
Date 2017-09-10.04:43:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505018633.44.0.63336226936.issue31373@psf.upfronthosting.co.za>
In-reply-to
Content
There's a (to my mind) unfortunate change in behaviour here. Under normal IEEE 754 rules, some C double values larger than FLT_MAX still round to FLT_MAX under conversion to float.

Python 3.6:

>>> import struct
>>> x = 3.40282356e38
>>> struct.pack("<f", x)
b'\xff\xff\x7f\x7f'

Following the changes in this PR:

>>> import struct
>>> x = 3.40282356e38
>>> struct.pack("<f", x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: float too large to pack with f format

The original behaviour is correct with respect to IEEE 754; the new behaviour is not. I think this is a case where the cure is worse than the disease.
History
Date User Action Args
2017-09-10 04:43:53mark.dickinsonsetrecipients: + mark.dickinson, haypo, benjamin.peterson
2017-09-10 04:43:53mark.dickinsonsetmessageid: <1505018633.44.0.63336226936.issue31373@psf.upfronthosting.co.za>
2017-09-10 04:43:53mark.dickinsonlinkissue31373 messages
2017-09-10 04:43:52mark.dickinsoncreate