Based on the Python / Matlab background, I would like to better understand how Julia Int64 overflow behavior works.
From the documentation :
In Julia, exceeding the maximum representable value of this type leads to step-by-step behavior.
julia> x = typemax(Int64)
9223372036854775807
julia> x + 1
-9223372036854775808
Now I have done some experimentation with numbers that are clearly larger than typemax (Int64), but the behavior that I see does not match the documentation. It seems that things do not always just wrap themselves around. Is only one wrapping allowed?
julia> x = (10^10)^(10^10)
0
julia> x = 10^10^10^10
1
julia> x = 10^10^10^10^10
10
julia> x = 10^10^10^10^10^10
10000000000
julia> typemax(Int64) > 10^19
true
julia > typemax(Int64) > -10^19
true
Can anyone shed light on the behavior that I see?
EDIT:
Why is 9 overflowing correctly and 10 is not working?
julia> 9^(10^14)
-1193713557845704703
julia> 9^(10^15)
4900281449122627585
julia> 10^(10^2)
0
julia> 10^(10^3)
0
Julia 0.5.0 (2016-09-19)
source
share