Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checked_* for div and mod functions #57

Open
JayXon opened this issue Dec 18, 2023 · 2 comments
Open

Add checked_* for div and mod functions #57

JayXon opened this issue Dec 18, 2023 · 2 comments

Comments

@JayXon
Copy link

JayXon commented Dec 18, 2023

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

@cuviper
Copy link
Member

cuviper commented Dec 29, 2023

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.

@JayXon
Copy link
Author

JayXon commented Dec 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants