3 ms·
> So here’s my wish: a signed integer where INT_MIN == -INT_MAX Just set INT_MIN to -127 and never use -128. > Second, you’re getting symmetry back. All the o
by dheera 4y ago
> So here’s my wish: a signed integer where INT_MIN == -INT_MAX
Just set INT_MIN to -127 and never use -128.
> Second, you’re getting symmetry back. All the operations mentioned above are now symmetric and can’t overflow. This makes them a lot easier to reason about.
But you seem to want the actual bits to be symmetric with the sign bit just being a literal + or -. This makes it easier for humans to reason with, but it does NOT make it easier for a CPU's adder to add -15 and +63, which in the current standard signed int implementation does not even require the CPU adder to know that it's a signed int.
Unsigned and signed int adding work exactly the same bit-wise, and can use the same hardwired circuits to process at blazing speed. That's the beauty of the current standard implementation.