top | item 35045563

(no title)

mh7 | 3 years 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.

discuss

order

circuit10|3 years ago

This would be terrible, the point of the type system is to stop you making mistakes by accidentally treating one type as another

mh7|3 years ago

How 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|3 years ago

That's how Java works. See >>>, compareUnsigned, divideUnsigned, parseUnsignedInt, etc.