Finite smallest float in Julia

I have a program in C++ which uses the definition of smallest finite double
double FPMIN = std::numeric_limits<double>::min() / EPS;
From reference: https://en.cppreference.com/w/cpp/types/numeric_limits/min
I’m trying to translate this program in Julia. However, Julia doesnt return a finite value when I run:

> typemin(Float64)/eps()
-Inf

Any suggestions on how I can get the smallest finite float or a good approximation to circumvent this problem?

nextfloat(0.0)?

2 Likes

You are probably looking for floatmin.

4 Likes

to add, your original snippet won’t work because

julia> typemin(Float64)
-Inf
3 Likes

Yes floatmin(), solves my problem!
Nextfloat(0.0) gives a very small number and seems to work, but for this particular code where I take 1/FPMIN later it returns Inf not being applicable.

floatmin returns “the smallest in absolute value non-subnormal value representable” (from doc). nextfloat(0.0) is subnormal.

6 Likes