This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author TD22057
Recipients TD22057, vstinner
Date 2008-10-13.21:13:31
SpamBayes Score 3.7087e-13
Marked as misclassified No
Message-id <1223932413.67.0.988624435556.issue4114@psf.upfronthosting.co.za>
In-reply-to
Content
I'm receiving a 32 bit floating point number encoded in binary format. 
The correct value for that number is 1.8183e-7 which can be expressed in
single precision just fine.  Given that the number in the binary
encoding is 1.8183e-7, I expected to get that back, not
1.818300034983622e-07 (which is NOT the closest double precision number
to the actual single precision number).

After doing some experiments, I think the problem is a basic fact of
life in C code which is that casting that single precision value to a
double precision one does not specify what happens in the extra digits.
 So I'm getting garbage in the extra digits when the struct module C
code casts the single to a double.  The problem is that C doesn't assume
that the non-precise digits are zero.

Since this is a function of the underlying C language, I'll withdraw the
bug.  (Hmm - I don't seem to have permission to do that)
History
Date User Action Args
2008-10-13 21:13:33TD22057setrecipients: + TD22057, vstinner
2008-10-13 21:13:33TD22057setmessageid: <1223932413.67.0.988624435556.issue4114@psf.upfronthosting.co.za>
2008-10-13 21:13:32TD22057linkissue4114 messages
2008-10-13 21:13:31TD22057create