What is the smallest number that can be represented in python?

What is the smallest number that can be represented in python?

I saw how small 2.05623357236e-296, but can it be less?

+4
source share
2 answers

Departure sys.float_info

>>> import sys
>>> sys.float_info 
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)

From the documents

min       DBL_MIN      minimum positive normalized float 
min_exp   DBL_MIN_EXP  minimum integer e such that radix**(e-1) is a normalized float

In my system, it is referred to as min=2.2250738585072014e-308

+6
source

Check it out sys.float_info.min. Please note that this is the minimum normalized value; the minimum denormalized value may be less, but numerical accuracy will suffer.

With the usual 64-bit floating-point numbers, the normalized min is approximately 2.2e-308. The denormalized minimum can be much less, up to 4.94e-324:

>>> 5e-324
4.9406564584124654e-324

, decimal module decimal , .

+4

Source: https://habr.com/ru/post/1611649/


All Articles