import math
var n0: int = 10^7
echo n0
var n1: int = 10*10^7
echo n1
var n2: int = 10^8
echo n2
Output:
10000000
100000000
Traceback (most recent call last)
temp.nim(8) temp
math.nim(346)
system.nim(2988)
Error: unhandled exception: over- or underflow [OverflowError]
Error: execution of an external program failed
Works for me on 64bit, but not 32bit. I guess the compiler's VM calculates with 64bit numbers, but the final program with 32bit numbers. You can explicitly use a 64bit int like this:
var n2 = (10'i64)^8
It's a bug in the exponentiation implementation that does an unnecessary multiplication at the end for even exponents.
Edit: Pull request for the fix has been submitted.