PeachPy icon indicating copy to clipboard operation
PeachPy copied to clipboard

Fix denormal double parsing

Open aschmolck opened this issue 1 year ago • 1 comments

Constant._parse_float64 blows up on denormal doubles. This PR fixes this, adds a few more test cases and also slightly cleans up _parse_float32 (missing base 16 for int call in an assertion, removal of always false test if mantissa_bits == 23 etc).

aschmolck avatar Sep 25 '23 15:09 aschmolck

For what it's worth, I'm not sure if there's some reason to prefer converting to a hex float literal and then parsing that to just doing something something like return struct.unpack("<Q", struct.pack("d", number))[0] for float64 and return struct.unpack("<L", struct.pack("f", number))[0] for float32.

I mostly stuck to the hex parsing approach because that's what the existing code was already using.

aschmolck avatar Sep 25 '23 15:09 aschmolck