Message74708
> Don't hesitate to reopen the bug if you consider that
> something should be fixed in Python.
I agree that it should be closed; people should read general CS
introductory material to learn how floating point numbers work.
> @loewis: Yes, the initial problem is about unpack("f", bytes). It's
> not possible to exact original 32 bits float value
Interestingly enough, it is possible - using the OPs approach.
If you want to truncate a 64-bit floating point number to a
32-bit one, pack it as float in the struct module, then unpack it.
Python will automatically pad the mantissa bytes with null bytes.
> because Python
> forces a conversion to 64 bits float. The behaviour should be
> documented.
I think it's documented somewhere that a Python float is represented
with a C double. That should suffice, IMO. |
|
Date |
User |
Action |
Args |
2008-10-13 22:36:06 | loewis | set | recipients:
+ loewis, vstinner, TD22057 |
2008-10-13 22:36:05 | loewis | link | issue4114 messages |
2008-10-13 22:36:05 | loewis | create | |
|