CPUs do wrap around operation to unsigned int. So I think saturated unsigned 
int operations always requires checking value everytime `+`, `-`, `*`, `div` or 
`mod` operaters are used and not as efficient as signed int.

There are algorithms (in crypt, hash, pseudo random number generator) that 
requires unsigned int with wrap around operations. For example, xoroshiro128+ 
used in Nim's stdlib uses wrap around addition. These algorithms don't use 
unsigned int to count something but just hold bit patterns. They use unsigned 
int addition or multiplication to randomize bit pattern.

There is saturate.nim in Nim compiler: 
<https://github.com/nim-lang/Nim/blob/devel/compiler/saturate.nim>

Reply via email to