Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closest true value to zero in Python

Tags:

python

A long time ago I read about the closest true value to zero, like zero = 0.000000001, something like that. In the article they mentioned about this value in Python and how to achieve it. Does anyone knows about this? I have look up here in SO but all the answers are about the closest value to zero of an array and that's not my point.

like image 792
John Avatar asked Nov 03 '25 07:11

John


1 Answers

The minimum positive denormalized value in Python3.9 and up is given by math.ulp(0.0) which returns 5e-324, or 4.940656e-324 when printed with format(math.ulp(0.0), '.7').

like image 115
haydenr4 Avatar answered Nov 04 '25 23:11

haydenr4