pythonfloating-point

Is sys.float_info machine specific?


I would like to know if sys.float_info.max/ sys.float_info.min are fixed values which are identical on all machines or does it depend on the machine's memory or other factors (and make the value different from machine to machine). Thank you!


Solution

  • It's relatively safe to assume those values will stay the same. They are specified by the IEEE 754 standard for "64bit binary floats", which all conventional Python installations use for their float values.

    See on what systems does Python not use IEEE-754 double precision floats for more details from a core developer.

    As noted in the above, the only known deviation is micropython which uses 32bit binary floats instead. However, given other constraints of micropython it's pretty safe to assume you're not going to be running there unless you know about it. For example, lots of the standard library doesn't exist which would break most conventional packages.