Python2.7 Default Float Precision
Does anyone know what is Python's default float precision value? Couldn't find anything via Google!
Solution 1:
import sys
print sys.float_info
Running this will give you something like this..
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
To know more about the values follow this link for official python docs.
Solution 2:
According to the Python 2 documentation:
On a typical machine running Python, there are 53 bits of precision available for a Python float, so the value stored internally when you enter the decimal number 0.1 is the binary fraction
0.00011001100110011001100110011001100110011001100110011010
which is close to, but not exactly equal to, 1/10.
Post a Comment for "Python2.7 Default Float Precision"