3 ms·
> This is (one reason) why Julia implemented a full, scheme-style, numeric tower right in the core language. What's the result of adding two i32 then? Is it an
by anonymoushn 4y ago
> This is (one reason) why Julia implemented a full, scheme-style, numeric tower right in the core language.
What's the result of adding two i32 then? Is it an i64? Doesn't the accumulator need to get wider on some additions, since adding an i64 to an i32 might also overflow an i64?
- e12e 4y agoActually, the default is overflow I now realize. But there is also automatic promotion, so: 0 + typemax(UInt8)+ typemax(UInt8) 510 While adding UInt8 first, then an implicit Int64 causes overflow: typemax(UInt8)+ typemax(UInt8) 254 (ie: 255 overflows to 254 - or is promoted and sums to 510) See: https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/ https://docs.julialang.org/en/v1/manual/integers-and-floatin... Try: https://julialang.org/learning/tryjulia/ https://julialang.org/learning/tryjulia/