Julia messes up integer exponents?

Julia uses actual machine integer arithmetic, which means that numbers can and do under- and overflow if you try to perform a computation outside of the range of values that can be represented by such an integer. See Integer overflow - Wikipedia for more general explanation.

If you actually need to deal with integers outside the range of a 64-bit Int, then you might want to use Julia’s built-in support for BigInt (which is much closer to the way integers behave in Python):

julia> big(10)^19
10000000000000000000

julia> big(10)^100
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Note that BigInts are substantially more expensive to work with than regular Ints (this is part of the reason why basic arithmetic in Python is slower than in Julia). If you want something that will be more efficient than a BigInt but without unexpected overflow or underflow, check out SaferIntegers.jl:

julia> using SaferIntegers

julia> SafeInt(10)^19
ERROR: OverflowError: 10^19
Stacktrace:
 [1] ^(::SafeInt64, ::SafeInt64) at /home/rdeits/.julia/packages/SaferIntegers/eMjmj/src/pow.jl:45
 [2] ^(::SafeInt64, ::Int64) at /home/rdeits/.julia/packages/SaferIntegers/eMjmj/src/pow.jl:71
 [3] macro expansion at ./none:0 [inlined]
 [4] literal_pow(::typeof(^), ::SafeInt64, ::Val{19}) at ./none:0
 [5] top-level scope at none:0
6 Likes