2 ms·
Ah, I totally thought this is about treating unsigned integers as 63 bits (which would use masked operations so that the top bit is always zero even on overflow
by flohofwoe 3y ago
Ah, I totally thought this is about treating unsigned integers as 63 bits (which would use masked operations so that the top bit is always zero even on overflow), while signed integers would use the full 64 bits with the MSB as sign bit. That way converting from unsigned to signed would always be 'safe' without requiring casting.
I sometimes use "width-1" integer types in Zig because Zig doesn't allow to assign an unsigned integer to a signed integer of the same width (e.g. assigning an u8 to an i8 is illegal without a cast, but assigning u7 to i8 is fine).