Message131235
[Robert]
> I have to disagree. It seems entirely reasonable to expect that
> unpack should return the same value passed to pack.
Robert: notice that a *Python* float (a *64-bit* C double internally) is here being stored as a *32-bit* float, losing precision. So no, it's not at all reasonable to expect that unpack should return the same value passed to pack---it's mathematically impossible for it to do so. There are (around) 2**64 distinct Python floats, and only 2**32 ways to pack them using '<f'.
When packing / unpacking using '<d', it *is* reasonable to expect the value to be recovered exactly, and as far as I know that's always what happens (barring peculiarities like NaN payloads not being reproduced exactly). |
|
Date |
User |
Action |
Args |
2011-03-17 08:15:37 | mark.dickinson | set | recipients:
+ mark.dickinson, loewis, vstinner, TD22057, Robert.Withrow |
2011-03-17 08:15:37 | mark.dickinson | set | messageid: <1300349737.55.0.568380566789.issue4114@psf.upfronthosting.co.za> |
2011-03-17 08:15:32 | mark.dickinson | link | issue4114 messages |
2011-03-17 08:15:32 | mark.dickinson | create | |
|