Since a very large floating value can be represented as follows:
sys.float_info.max and float("inf").
Is one better than the other? If yes, under what circumstances?
Or which is one more preferred for scientific computing?
Definitely not the first:
>>> import sys
>>> sys.float_info.max
1.7976931348623157e+308
That's the largest finite float.
You're missing the preferred method ;-)
>>> import math
>>> math.inf
inf
Note also:
>>> math.nan
nan
This should indirectly tell you everything you need to know:
>>> float('inf') > sys.float_info.max
True
>>> float('inf') <= sys.float_info.max
False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With