Closed mvdan closed 6 years ago
This is already implemented. x ~mod+ y
will add while ignoring overflow. There's also the x ~mod+= y
form that's analogous to the +=
operator. An example of its use is in std/adler32/common_adler32.wuffs
. For that particular case, it's not as though the computation will actually overflow, but using ~mod+
instead of a plain +
makes the proof checking easier.
It's a little verbose, but breaking it down:
~
means an overflow-concious operator.mod
says overflow is treated as modular arithmetic (the sat
form chooses saturating arithmetic).+
means, y'know, plus.
Sometimes it is really wanted. All I could find in the repo is:
I presume that means it is planned?