15.2. Math Precision

15.2.1. Minimal and Maximal Values

Maximal and minimal float values:

import sys

sys.float_info.min      # 2.2250738585072014e-308
sys.float_info.max      # 1.7976931348623157e+308

15.2.2. Infinity

Infinity representation:

1e308                   # 1e+308
-1e308                  # -1e+308

1e309                   # inf
-1e309                  # -inf

float('inf')            # inf
float('-inf')           # -inf

float('Infinity')       # inf
float('-Infinity')      # -inf

15.2.3. Not-a-Number

float('nan')
# nan

float('-nan')
# nan

15.2.4. NaN vs Inf

float('inf') + float('inf')     # inf
float('inf') + float('-inf')    # nan
float('-inf') + float('inf')    # nan
float('-inf') + float('-inf')   # -inf

float('inf') - float('inf')     # nan
float('inf') - float('-inf')    # inf
float('-inf') - float('inf')    # -inf
float('-inf') - float('-inf')   # nan

float('inf') * float('inf')     # inf
float('inf') * float('-inf')    # -inf
float('-inf') * float('inf')    # -inf
float('-inf') * float('-inf')   # inf

float('inf') / float('inf')     # nan
float('inf') / float('-inf')    # nan
float('-inf') / float('inf')    # nan
float('-inf') / float('-inf')   # nan