Reputation: 17121
How does one get the maximum and minimum values of a Number type like an Integer or a Float?
max_value(Int)
Upvotes: 10
Views: 7867
Reputation: 91
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
Upvotes: 7
Reputation: 6388
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.
Upvotes: 20