Bug in floating point multiplication

Jonas Wielicki jonas at wielicki.name
Mon Jul 6 10:26:33 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512



On 02.07.2015 19:29, Jason Swails wrote:
> // maths.h #include <math.h> #include <stdio.h>
> 
> int main() { double x; int i; x = 1-pow(0.5, 53);
> 
> for (i = 1; i < 1000000; i++) { if ((int)(i*x) == i) { 
> printf("%d\n", i); break; } }
> 
> return 0; }

Does not show the problem on either -m32 or normal on my Fedora 22,
64-bit with any of:

Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (inside a qemu though, where
it shows "Intel Core Processor (Haswell)")
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz

Unfortunately, I fried my AMD Bulldozer last week, so I cannot check
there.

regards,
jonas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJVmjunAAoJEMBiAyWXYliKzDwP+wcCn9AW7EdZ/gHEmw6vW9sL
MFUszpPQ3+HYPLuMn35tAy31GDozCBHze8AISHzL0oWCj6u1x7z4gxY0MKaAsRuh
Gp5R5W+KHpE0tYps65SHUFUxCvf5YSR4vao6PeUMsSNxdCZ5HVa6dPpdYe0wWho4
D+6HV5RT7LCKC4+u1iNrJL3ldBPCH73+0FY0IajC0/w3QDCOpQEUVRKDCQdARq3W
I4FYeU3I3jfUH7694gUgRDECYt16k53G3dU2J5r+ZXmFX6SUWxgL3McXdxpUpGZo
VnPGcvMeWEq1qRxkREphGtgaMz+NxX8im9jp9RZX3KD7uWSecEt4SrQJavLejRWg
vb0i+pe3Df64bT+1in4JxHV6UlEdULA+0/pP+S9OyYzydKDzPBWBuFe23WjsdDJi
sdRrUHCAyAr7sulfOiU92q+/ROgCW+sCD83TNFQdQ/kNsaXioYmW3Rc7jOoWPetN
Uqq6ezZqkfUmichqggZi5ogyDUyfLvfHoe3dpecun95ArTcsZXpVW8kddP3kYANv
3zldmQfTjCzDWc2EPCpRfs9gFn7AaWM9t4jiyIStTQoYId7mHcRbTmb2DwT/XsPY
Ulopha+6PhkGw0ejmbFYx2juvOZlSegTRhHnRe/+9QRtfpyqOFjHB92ai+g3H/g6
NSN8EA+7w3sc8/r31k7O
=7GrS
-----END PGP SIGNATURE-----


More information about the Python-list mailing list