Martin v. Löwis <[EMAIL PROTECTED]> added the comment:

> 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.

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4114>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to