ID EN
Sys

float_info

Python 3.11

A named tuple holding information about the float type. It contains low level information about the precision and internal representation. The values correspond to the various floating-point constants defined in the standard header file float.h for the ‘C’ programming language; see section 5.2.4.2.2 of the 1999 ISO/IEC C standard [C99], ‘Characteristics of floating types’, for details.

Syntax

PYTHON
sys.float_info

Examples

Example 1
PYTHON
>>> import sys
>>> sys.float_info.dig
15
>>> s = '3.14159265358979'     decimal string with 15 significant digits
>>> format(float(s), '.15g')   convert to float and back -> same value
'3.14159265358979'
Example 2
PYTHON
>>> s = '9876543211234567'     16 significant digits is too many!
>>> format(float(s), '.16g')   conversion changes value
'9876543211234568'

See Also

named tuple [C99] named tuple math.ulp() math.ulp(0.0) sys.float_info.dig sys.float_info.dig