Message74696
The problem is not from Python but from your FPU during the conversion
from 64 bits float to 32 float (made by struct.pack). Example in C:
#include <stdio.h>
int main()
{
float f;
double d;
d = 1.8183;
printf("d=%.20f\n", d);
f = (float)d;
d = (double)f;
printf("f=%.20f\n", f);
printf("d=%.20f\n", d);
return 0;
}
Result:
d=1.81830000000000002736 # ok
f=1.81830000877380371094 # 64->32: loose precision
d=1.81830000877380371094 # 32->64: no change |
|
Date |
User |
Action |
Args |
2008-10-13 21:21:02 | vstinner | set | recipients:
+ vstinner, TD22057 |
2008-10-13 21:21:02 | vstinner | set | messageid: <1223932862.59.0.26580854156.issue4114@psf.upfronthosting.co.za> |
2008-10-13 21:21:01 | vstinner | link | issue4114 messages |
2008-10-13 21:21:00 | vstinner | create | |
|