3 ms·
> There seems no sensible reason why ints are 32 bit on a 64 bit platform Try storing a few billion of them, they're half the size. > In C code that we write,
by nullc 10y ago
> There seems no sensible reason why ints are 32 bit on a 64 bit platform
Try storing a few billion of them, they're half the size.
> In C code that we write, we have a rule that every use of plain 'int' must be justified - it's a "code smell"
Current MISRA C requires this.
- jakub_h 10y agoYou could also pack three 20-bit numbers into a 64-bit word, if you needed it. Then again, the C family languages are kind of weird about that.
- wolf550e 10y agoUnicode code points are 21 bits long. I wonder if something out there stores strings by packing 3 code points per uint64_t.
- charleslmunger 10y agoMaybe, but almost everything outside the basic multilingual plane is so infrequently used that it's a waste of space to use a fixed-width format. But I could see it being a useful replacement for UTF-32... If you need to be able to calculate code points in constant time, and you don't mind wasting one bit out of every 64. Self synchronizing, constant time code point count from buffer size, and close to as space efficient as UTF-16, but with none of the surrogate mess.