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

integer-overflow-or-underflow detector #276

Closed
jgcrosta opened this issue Jul 24, 2024 · 0 comments · Fixed by #277
Closed

integer-overflow-or-underflow detector #276

jgcrosta opened this issue Jul 24, 2024 · 0 comments · Fixed by #277
Assignees

Comments

@jgcrosta
Copy link
Collaborator

To explicitly handle the possibility of overflow, you can use these families of methods provided by the standard library for primitive numeric types:

  • Wrap in all modes with the wrapping_* methods, such as wrapping_add.
  • Return the None value if there is overflow with the checked_* methods.
  • Return the value and a boolean indicating whether there was overflow with the overflowing_* methods.
  • Saturate at the value’s minimum or maximum values with the saturating_* methods.

Reference: https://doc.rust-lang.org/book/ch03-02-data-types.html#integer-overflow

@jgcrosta jgcrosta self-assigned this Jul 24, 2024
@jgcrosta jgcrosta linked a pull request Jul 25, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant