4 ms·
Ok, then it would make sense to have ONE datatype that fits a register. But it would make more sense that the other types (char, short, long) are a known and fi
by chihuahua 3y ago
Ok, then it would make sense to have ONE datatype that fits a register. But it would make more sense that the other types (char, short, long) are a known and fixed size. Otherwise, what's the use case for short? "I need something that's smaller than a register, but I don't care what range it can store?"
- ajross 3y agoFWIW "short" has always been 16 bits. It was introduced with VAX Unix (and a few other 32 bit architectures) so that you could easily port code that assumed 16 bit arithmetic. The point isn't that, today, you'd choose to do what C did. But in 1977 there weren't a lot of other options. Early C did indeed have fixed, defined types. But moving to the VAX messed all that up. They had to choose to either add new types (and thus turn a bunch of code that would otherwise run fast on the VAX into weirdly-interpreted nonsense) or update the existing types so that idiomatic PDP-11 code still did what you expect most of the time. They chose the latter.