num-traits icon indicating copy to clipboard operation
num-traits copied to clipboard

Add trait for wrapping_div and wrapping_rem

Open lukyxu opened this issue 3 years ago • 1 comments

There exist traits for wrapping_add, wrapping_sub, wrapping_mul, wrapping_shl, wrapping_shr and wrapping_neg. Is there a reason why there isn't a trait for wrapping div and wrapping rem?

lukyxu avatar May 19 '22 02:05 lukyxu

No particular reason, just that nobody has wanted them yet.

I'm not sure it's very useful to have these in generic contexts -- the only input that actually wraps is signed MIN / -1. Division by zero still panics, at least. But if you have a use case, I wouldn't mind a pull request for new traits.

cuviper avatar May 20 '22 18:05 cuviper