Message400434
Hi all!
I have this case when trying to get a float value applying pack to these integer values:
struct.unpack('f', struct.pack('HH', 0, 32704))
This happens when executing the unpack function to a float format, from a bit-array where the sign bit is not in a suitable position I think. Applying big-endian to the format, it returns a numeric value, but being little-endian it returns a NaN.
> struct.unpack('<f', struct.pack('HH',0, 32704))
Out[168]: (nan,)
> struct.unpack('>f', struct.pack('HH',0, 32704))
Out[169]: (6.905458702346266e-41,)
The current documentation on struct.unpack doesn't anything about what conditions a NaN is returned, besides this might be a expected value. Maybe explaining how this value could be converted to an equivalent format to retrieve the proper value may help, or why this returns a NaN and how to avoid it.
Thanks in advance. |
|
Date |
User |
Action |
Args |
2021-08-27 17:13:38 | jrojas | set | recipients:
+ jrojas |
2021-08-27 17:13:38 | jrojas | set | messageid: <1630084418.34.0.275202976554.issue45032@roundup.psfhosted.org> |
2021-08-27 17:13:38 | jrojas | link | issue45032 messages |
2021-08-27 17:13:38 | jrojas | create | |
|