Floating-point multiplication
Alex Holkner
xander at yifan.net
Mon Feb 4 20:50:12 EST 2002
I'm experiencing discrepencies in floating point multiplication between the
Python interpreter and embedded python. Running Python 2.2 under Win2k,
compiling with VC++. The interpreter gives:
>>> print sys.version
'2.2 (#28, Jan 4 2002, 19:01:19) [MSC 32 bit (Intel)]'
>>> print 0.785398163397 * 4.0
3.14159265359
>>> print math.pi
3.14159265359
Which is expected. Under my embeddeded python, however:
print sys.version
'2.2 (#28, Jan 4 2002, 19:01:19) [MSC 32 bit (Intel)]'
print 0.785398163397 * 4.0
3.14159274101
print math.pi
3.14159274101
Which is quite wrong, and is upsetting 'import random', which requires
math.pi to be within a certain tolerance.
I expect that this problem is related to the runtime C libraries in use,
however both the interpreter and embedded python22.lib/python22.dll were
compiled from the source. Building Debug vs. Release does not make a
difference.
Thanks,
Alex.
More information about the Python-list
mailing list