How does one get the maximum and minimum values of a Number type like an Integer or a Float?
max_value(Int)
For questions like this, you will be best served by looking at the julia docs https://docs.julialang.org/en/v1/base/base/#Base.typemin
Specifically for this question, typemin(Int)
, and typemax(Int)
should do what you want.
But typemax(Float64)
gives 'Inf' which is probably not what the author wanted.
The trick is to use prevfloat(typemax(Float64))
which is not that obvious.
julia> typemax(Float64)
Inf
julia> prevfloat(typemax(Float64))
1.7976931348623157e308
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With