On Tuesday, 11 December 2012 at 12:53:38 UTC, monarch_dodra wrote:
integer operations are always promoted to at least int. That's standard fare since C. I think it is a performance thing: Unpack into ints, oeprate, repack into ints.
If memory serves me right, promotion to int is based more on CPU efficiency and code size than anything else (and yes packing and unpacking takes some 6 extra steps). Also with libraries possibly written by different compilers may have different results if they don't all agree on a common (default) type to return.
Also most x86 operations for ints can be written as 1 byte opcodes, although for modern CPUs that kind of code generation may not be as efficient as it used to be.
http://www.codeproject.com/Articles/6154/Writing-Efficient-C-and-C-Code-Optimization
