It\'s well known that comparing floats for equality is a little fiddly due to rounding and precision issues.
For example: https://randomascii.wordpress.com/2012/02/2
I'm not aware of anything in the Python standard library (or elsewhere) that implements Dawson's AlmostEqual2sComplement
function. If that's the sort of behaviour you want, you'll have to implement it yourself. (In which case, rather than using Dawson's clever bitwise hacks you'd probably do better to use more conventional tests of the form if abs(a-b) <= eps1*(abs(a)+abs(b)) + eps2
or similar. To get Dawson-like behaviour you might say something like if abs(a-b) <= eps*max(EPS,abs(a),abs(b))
for some small fixed EPS
; this isn't exactly the same as Dawson, but it's similar in spirit.