In python to get the smallest positive usable number for a float you can use:
numpy.finfo(float).tiny
Julia implement the function eps
, but I don’t see nothing similar to tiny.
Thanks.
In python to get the smallest positive usable number for a float you can use:
numpy.finfo(float).tiny
Julia implement the function eps
, but I don’t see nothing similar to tiny.
Thanks.
What does usable mean? Do you mean eps(0.0)
?
I don’t know what’s means “mean”. But it’s not the same as eps(0.0)
.
python:
np.finfo(float).tiny
Out[1]: 2.2250738585072014e-308
julia:
julia> eps(0.0)
5.0e-324
I’m translating code from python and this tiny
function is use in a max
function as a minimum value for a variable.
Hmm, the numpy docs really do say that.
More precisely, this is the smallest magnitude normal floating point number, which is available in Julia via realmin(Float64)
.
It makes sense.
Thanks.
The positive normal Float64 value of least magnitude is
realmin(Float64) == 2.2250738585072014e-308
;
the least negative normal Float64 is -realmin(Float64)
.
These are smallest Float64 values that are normally represented.
They are not the smallest Float64 values that are usable. Those are
subnormal (values with less precision used for the significand).
The most pos subnormal Float64 is 2.2250738585072009e-308.
The least pos subnormal Float64 is 4.9406564584124654e-324.
There are corresponding negative values.
As an update to this thread, looks like the new function is floatmin:
help?> floatmin
search: floatmin floatmax float flatten Float16 Float32 Float64 findmin Cfloat
floatmin(T = Float64)
Return the smallest positive normal number representable by the floating-point
type T.
On a x86_64:
julia> floatmin(Float32)
1.1754944f-38
julia> floatmin(Float64)
2.2250738585072014e-308