Mark Dickinson <dicki...@gmail.com> added the comment:

This isn't a bug: floating-point arithmetic is by its nature approximate, and 
two sequences of operations that would mathematically give the same result need 
not give the same result with floating-point.

I'd recommend a read of this portion of the tutorial, which goes into some of 
the issues involved: https://docs.python.org/3/tutorial/floatingpoint.html

Having said that, you'll get slightly better accuracy in general (one can't 
make specific guarantees, since everything's dependent on the platform's math 
library) if you use `math.sqrt(x)` instead of `math.pow(x, 0.5)`, and 
`math.log2(y)` instead of `math.log(y, 2)`.

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36055>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to