[Tutor] precision handling

Alan Gauld alan.gauld at yahoo.co.uk
Thu Sep 30 16:20:42 EDT 2021


On 30/09/2021 09:07, Msd De wrote:
> Hello,
> The two same numbers generated in python 2.7 when subtracted should give
> zero. Instead it gives - 4.7393372903e-07.

You do realize that Python 2.7 is unsupported legacy software?
You should really be using Python 3 by now.

> The number are given below:
> 
> 176697092.941 - 176697092.941 = - 4.7393372903e-07

Not in any version of python I've tried - including 2.7.

Can we see your actual code and output?
And which OS too, just to be sure.

-- 
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