Re:Almost Always Unsigned
by kazinator on Sunday January 02, 2022 @11:27AM
(#29770071)
Important: without silent conversion. Languages like Pascal and Ada require explicit conversions in more places to make that sort of thing useful.
[ Parent
| on HN ]
It also allows creating type checked "new" numerical types for semantics purposes to help improve interfaces. This helps prevent things like accidentally passing an integer in the wrong units for example. Two of the worst offenders I've seen of this is: "Is this uint64_t (or float) "dt" parameter in ticks, seconds, milliseconds, microseconds or nanoseconds?" and "Is this angle parameter in radians or degrees?"