4 Oct
2016
4 Oct
'16
2:43 p.m.
On 4 October 2016 at 21:32, Arek Bulski
I had a bug where nan floats failed to compare equal because there seems to be more than one nan value and comparison seems to be binary based.
"NaN != NaN" is part of the definition of IEEE 754 floats: https://en.wikipedia.org/wiki/NaN#Floating_point That's why it returns False even if you compare a specific NaN instance with itself: >>> x = float("nan") >>> x == x False If you need a kinda-like-NaN value that provides reflexive equality, then Python's None singleton is a better fit. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia