[OT] The Usual Arithmetic Confusions

Paul Backus snarwin at gmail.com
Fri Feb 4 21:54:39 UTC 2022


On Friday, 4 February 2022 at 21:13:10 UTC, Walter Bright wrote:
> The integral promotion rules came about because of how the 
> PDP-11 instruction set worked, as C was developed on an -11. 
> But this has carried over into modern CPUs. Consider:
>
[...]
>
> You're paying a 3 size byte penalty for using short arithmetic 
> rather than int arithmetic. It's slower, too.
>
> Generally speaking, int should be used for most calculations, 
> short and byte for storage.

Sure. That's a reason why I, the programmer, might want to use 
int instead of short or byte in my code. But if, for whatever 
reason, I've chosen to use short or byte in spite of the 
performance penalties, I would rather not have the language 
second-guess me on that choice.


More information about the Digitalmars-d mailing list