News for hackers. Stuff that matters.
Re:Almost Always Unsigned by kevin_thibedeau on Sunday January 02, 2022 @03:04PM (#29773144)
It isn't about squeezing out extra range. A silent overflow mechanism with predictable behavior is useful and can't be cheaply replicated with signed numbers.

Timestamp arithmetic is a common case where unsigned integers with silent overflow is superior. You can avoid bounds checks and special cases by always computing a delta between a newer time and an earlier time. As long as you can guarantee that the sample period is less than the clock rollover period there will never be any ambiguity.

Ada tried imposing the purity of signed integers and had to add modular types to get these semantics because of their utility.

There are no comments on this comment yet.