[Tutor] A couple newbie questions about Python
Alan Gauld
alan.gauld at btinternet.com
Thu Jun 12 15:30:55 CEST 2014
On 12/06/14 09:18, Mark Lawrence wrote:
> Besides Alan's previous statement about using integers you can also use
> things like Python's decimal module see
> https://docs.python.org/3/library/decimal.html#module-decimal
Although Decimal doesn't solve the issue of rounding errors for
financial calculations (neither do pennies) nor the issues of
repeating results like 1/7.... It just moves them into the
more familiar territory of decimal numbers rather than binary.
So at least what you write is represented accurately.
As Steven said in his reply, floating point on computers is hard.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list