On 10/17/2011 6:31 AM, Sagar Shankar wrote:
Hi, this is my first question to this group. I'm a beginner to computer science and programming in Python. Am currently using John Zelle's book - Python Programming: An introduction to computer science to teach myself. It is not crucial here - but you must recognize that your program uses floating point numbers, which almost always are an approximation to the "real" value. For example (assuming decimal numbers): >>> 4/3.0 1.3333333333333333 (followed by an unending number of 0's). The "real" value of 4/3.0 is 1 followed by an unending number of 3's. Each successive fraction's floating point value will be "off" by some relatively small value. Those errors will probably add up. Another limitation of floating point numbers is that there is a maximum and a minimum exponent. Eventually the fractions will be too small to convert to float, raising an overflow exception. Allof this raises the question - what computer algorithms successively approximate pi exactly? -- Bob Gailer 919-636-4239 Chapel Hill NC |
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor