3 ms·
I like Zig's approach here: normal arithmetic had undefined overflow behavior, but if you want overflow there's the overflow arithmetic operators +% -% *% and ÷
by AnIdiotOnTheNet 5y ago
I like Zig's approach here: normal arithmetic had undefined overflow behavior, but if you want overflow there's the overflow arithmetic operators +% -% *% and ÷%, and I think saturating arithmetic operators (+| -| *| ÷|) just landed in the master.
- masklinn 5y agoDedicated operators is OK, but IME the semantics are value-level e.g. one value is overflowing while the other is saturating. In that sense, I think Rust' `Wrapping<T>` is really nice though the ergonomics are not ideal.