3 ms·
Signed and unsigned should both go, there should only be wordN types (word8, word16, etc) with two's complement semantics. Then you can have explicit functions
by mh7 4y ago
Signed and unsigned should both go, there should only be wordN types (word8, word16, etc) with two's complement semantics.
Then you can have explicit functions for the operation you want: signed_mul(), signed_less_than(), unsigned_greater_than(), add_assume_no_overflow(), etc.
(add your favorite syntactic sugar/operator symbols for these).
Assembly is more explicit and clearer to understand in this regard.
- circuit10 4y agoThis would be terrible, the point of the type system is to stop you making mistakes by accidentally treating one type as another
- mh7 4y agoHow would you make a mistake? The only time signed vs unsigned matters is for comparisons and mul/div, and those have explicit names so you're never surprised that 0xFFFFFFFF is less than 0 when doing signed_less_than().
- edflsafoiewq 4y agoThat's how Java works. See >>>, compareUnsigned, divideUnsigned, parseUnsignedInt, etc.