[Edu-sig] Math weirdness?

Chris Meyers cmeyers@guardnet.com
Wed, 03 Oct 2001 12:44:41 -0700


10/03/2001 9:03:17 AM, Robert Rickenbrode II <rkr_ii@yahoo.com> wrote:

Interestingly, I get different results on Python 1.5.2 running on a Sparc.  For one thing the precision is lower. math.pi is 
3.14159265359, and rounding it correctly gives 3.142. 10.0/3 gives 3.33333333333  again 12 digit accuracy. So I think there 
is a question whether later versions of Python have broken something in floating point calcuations.

Chris

>Hey folks, can someone explain these to me:
>
> >>> import math
> >>> math.pi
>3.1415926535897931
> >>> round (math.pi, 3)
>3.1419999999999999
> >>>
>
>
>and this:
>
> >>> 10./3
>3.3333333333333335
>
>These are taken from IDLE on a Win98 machine running Python 2.1.1:
> >>> import sys
> >>> print sys.version
>2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]
>
>Thanks, Rob
>
>Robert K. Rickenbrode II
>rkr_ii@yahoo.com
>
>
>_______________________________________________
>Edu-sig mailing list
>Edu-sig@python.org
>http://mail.python.org/mailman/listinfo/edu-sig
>