I am with Julia 1.9 on a fresh session (windows). (Maybe it happens on previous version already)
Is it normal to get stuff like
julia> 5^2000
-7794321243379011391
julia> 2^200
0
With floating power 5^2000.
, it is Inf
.
I am with Julia 1.9 on a fresh session (windows). (Maybe it happens on previous version already)
Is it normal to get stuff like
julia> 5^2000
-7794321243379011391
julia> 2^200
0
With floating power 5^2000.
, it is Inf
.
That is just integer overflow. Normal julia Ints aren’t BigInts.
Why not Inf
everywhere?
Inf is a floating point thing. One could use checked integer arithmetic that would throw an exception on overflow like GitHub - JeffreySarnoff/SaferIntegers.jl: These integer types use checked arithmetic, otherwise they are as system types.. But they are slow, so julia doesn’t do that by default
For the second time this week I can dig out this classic thread:
And I’ll plug OverflowContexts.jl (GitHub - BioTurboNick/OverflowContexts.jl: Fine control of integer overflow checking.) if you’d like control over it.
Why not
Inf
everywhere?
Because Inf is NOT a part of Int64
Thanks for all your answers, I missed these link in my pre-question search.
Plus I missed Julia docs on that.
I missed the “overflow” keyword.