You can’t rely on (and users don’t really opt in to Int
or Int64
so much, I think they use out of habit, as that’s the default, which is my main message):
julia> typemax(Int)
9223372036854775807
On 32-bit it’s “only” 2147483647, but yes, that’s already very generous (while more likely to overflow, e.g. for intermediate calculations like the distance calculation I showed, would for x or y as high as 46341 or 32-bit), why I suggested Int21
as a happy medium with 1048576 as a maximum, for input data, for output (and all intermediate numbers), the sky is the limit. If I learned anything from Steve Jobs/macOS, then it’s sensible defaults are good. I do not rule out smaller types used, just not as defaults, if you need to chose one.
EDIT: I assumed ^
would give you Int32 on 32-bit, but actually Int32 input for it or *
widens to Int64 output (but Int8, Int16 and Int64 do not widen), at least on 64-bit, so my idea is already partially implemented, while it can still overflow for Int64 input, and most likely will for Int16 or smaller.