Python wierdness

Mark Jackson mjackson at wc.eso.mc.xerox.com
Wed Feb 7 16:52:28 EST 2001


"Roger H" <rhyde99 at email.msn.com> writes:

> What's going on here, and how could one get around it?

Display rounding of finite-precision floating point arithmetic:

yngvi> python
Python 1.5.2 (#7, May  6 1999, 14:39:45)  [GCC 2.8.1] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 0.3 % 0.1 - 0.1
-2.77555756156e-17

In other words, 0.3 % 0.1 == 0.1 is indeed false.

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
	Having your book made into a movie is like having
	your ox made into a bouillon cube.
				- Bill Neely





More information about the Python-list mailing list