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

Add checked_* for div and mod functions

Open JayXon opened this issue 2 years ago • 2 comments

It's very easy to implement the check wrong, most people only check if denominator is 0, but not i32::MIN / -1.

JayXon avatar Dec 18 '23 08:12 JayXon

There are already traits for this: https://docs.rs/num-traits/latest/num_traits/ops/checked/index.html

But if you're asking for this on Integer, I don't think there's any compatible way to add these as extra methods.

cuviper avatar Dec 29 '23 22:12 cuviper

Sorry I should've been more clear, I was talking about functions like div_floor, div_mod_floor, mod_floor I don't see a trait for checked variants of these

JayXon avatar Dec 29 '23 22:12 JayXon