value of pi and 22/7

Ian Kelly ian.g.kelly at gmail.com
Thu Mar 17 13:01:54 EDT 2011


On Thu, Mar 17, 2011 at 10:57 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Thu, Mar 17, 2011 at 10:46 AM, kracekumar ramaraju
> <kracethekingmaker at gmail.com> wrote:
>> I tried the following
>>>>> 22/7.0
>> 3.1428571428571428
>>>>> import math
>>>>> math.pi
>> 3.1415926535897931
>>>>>
>>
>>
>> Why is the difference is so much ?is pi =22/7 or something ?
>
> Pi is not 22/7.  That is just a commonly-used approximation.

I should add that math.pi is also not pi, because pi cannot be exactly
represented as a floating-point number.  It is another approximation
that has several more digits of precision than 22/7.



More information about the Python-list mailing list