There's been many discussions of this before. The basic premise is simple: all integer arithmetic is done in your native word size. When you store that result somewhere, it is converted to the storage type. Since you can do most operations on Int64s and then convert to Int32 and get the exact same answer, this works out fine. I have yet to hear a really convincing argument for why we shouldn't just do everything in native int size.
On Sat, Mar 1, 2014 at 6:26 PM, Stefan Karpinski <[email protected]>wrote: > On Fri, Feb 28, 2014 at 8:49 AM, andrew cooke <[email protected]> wrote: > >> defining >> Base.promote_rule(::Type{Int32}, ::Type{Int32}) = Int32 >> doesn't help either, and i'm not sure why. >> > > Promotion only applies when the types don't already have the same type. > When you write int32(1) + int32(2) you call this method: > https://github.com/JuliaLang/julia/blob/master/base/int.jl#L16, which > explicitly converts the values to your native Int type and then does the > work. >
