In my understanding, sys.float_info.max
is the largest possible float value. However, it seems that comparing such large values fail.
import math
import sys
m = sys.float_info.max # type 'float'
m == m # True
m < m # False
m > m # False
m == m-1.0 # True
m < m-1.0 # False
m > m-1.0 # False
m == m-1e100 # True
m < m-1e100 # False
m > m-1e100 # False
m == m-1e300 # False
m > m-1e300 # True
m < m-1e300 # False
I assume that's because of the limited precision? If so, in what numerical range can i operate safely?
The above code was run with Python 3.5.2.