Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: smallest denormalized double error

Using WinPython 3.4.4.2, I get the following weird result:

>>> 2**-1075
5e-324

That is, the same as 2**-1074, whereas 2**-1075 should be zero in double float representation. With Python 3.5.1 at the address https://www.python.org/shell/, I get 0 as expected.

May anybody help me to understand what's going wrong?

Thank you

like image 601
Tig la Pomme Avatar asked May 30 '26 14:05

Tig la Pomme


1 Answers

The smallest re-presentable denormalized floats larger, and smaller, than zero are: 5e-324 and -5e-324.

5e-324 is the denormalized minimum which can be achieved by multiplying minimum floating point number(2.2250738585072014e-308) with floating point epsilon(2.220446049250313e-16).

import sys
print(sys.float_info.min*sys.float_info.epsilon) 

Output:

5e-324

I also get the same result in my shell (Python 3.5.1). The address https://www.python.org/shell/ uses console from http://www.pythonanywhere.com/ which might control such operation in their system.

like image 159
arsho Avatar answered Jun 02 '26 04:06

arsho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!