3 ms·
That's just integer overflow.
by ChrisRackauckas 8y ago
That's just integer overflow.
- kgwgk 8y agoI know. But I don't think that's the correct (floating point) result most people would expect, so it's worth signaling. julia> 2^62 4611686018427387904 julia> 2^63 -9223372036854775808 julia> 2^64 0
- FabHK 8y agoTo be fair, though, this behaviour (namely, staying close to machine arithmetic) has been discussed and decided upon, and advertised. It's what enables the speed. C/C++ makes the same choices, by and large.
- kgwgk 8y agoI don't think C/C++ have integer exponentiation so even C/C++ programmers may be surprised here. I don't know if the behaviour of the power operator when both numbers are integers (and depending on whether the exponent is negative or positive) is mentioned in the documentation.
- krull10 8y agoThis is something that was just heavily discussed on the Julia Discourse, with a big back and forth between individuals used to the computer integer arithmetic rules vs people wanting Python like functionality. Based on the confusion there, it definitely seems that it could be made clearer in the docs that if one wants floating point results one needs to use 10.0^17 instead of 10^17.
- deleted 8y ago[deleted]