3.1. Math Precision¶

3.1.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


3.1.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


3.1.3. Not-a-Number¶

float('nan')
# nan

float('-nan')
# nan


3.1.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