[Tutor] Count for loops
Alan Gauld
alan.gauld at yahoo.co.uk
Tue Apr 11 16:43:18 EDT 2017
On 11/04/17 19:44, Mats Wichmann wrote:
> import decimal
>
> Pi_Number =
> str(decimal.Decimal(3.14159265358979323846264338327950288419716939))
>
Unfortunately that doesn't work either:
>>> " " + str(decimal.Decimal(
... 3.14159265358979323846264338327950288419716939))
' 3.141592653589793115997963468544185161590576171875'
>>>
Notice the output is both longer and has completely different
numbers in the last half of the result.
> topic. The decimal module documentation contains this pithy comment near
> the top:
>
> Decimal “is based on a floating-point model which was designed with
> people in mind, and necessarily has a paramount guiding principle –
> computers must provide an arithmetic that works in the same way as the
> arithmetic that people learn at school.”
But sadly they haven't beat the problem of storing high precision
decimal numbers in binary storage.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list