Add checked, wrapping and saturating arithmetic for rem/mod#230
Merged
kimikage merged 2 commits intoJuliaMath:masterfrom Sep 19, 2020
Merged
Add checked, wrapping and saturating arithmetic for rem/mod#230kimikage merged 2 commits intoJuliaMath:masterfrom
rem/mod#230kimikage merged 2 commits intoJuliaMath:masterfrom
Conversation
The default arithmetic for `rem` is still checked arithmetic. This also adds the support for 3-arg `rem`. In `RoundUp` mode, `rem` causes `OverflowError` with unsigned (i.e. `Normed`) values. Otherwise, `rem`/`mod` does not cause an overflow.
This prevents MethodError due to lexical replacement of `x % X`.
This was referenced Sep 15, 2020
Codecov Report
@@ Coverage Diff @@
## master #230 +/- ##
==========================================
+ Coverage 95.42% 95.55% +0.13%
==========================================
Files 6 6
Lines 677 698 +21
==========================================
+ Hits 646 667 +21
Misses 31 31
Continue to review full report at Codecov.
|
timholy
approved these changes
Sep 18, 2020
Member
timholy
left a comment
There was a problem hiding this comment.
I really like how much you've been able centralize here, nice work as always!
Collaborator
Author
|
There is a bit more discussion about what to do with these arithmetic methods in v0.9.0, but I'll merge this first. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default arithmetic for
remis still checked arithmetic.saturating_{rem|mod}behaves somewhat strangely in the case of the overflow. (cf. #221 (comment))This also adds the support for 3-arg
rem. OnlyRoundToZero(default),RoundDown(mod), andRoundUpare supported. InRoundUpmode,remcausesOverflowErrorwith unsigned (i.e.Normed) values. Otherwise,rem/moddoes not cause an overflow.This also adds dummy checked, wrapping and saturating
remfor type modulus to preventMethodErrordue to lexical replacement ofx % X.This completes the implementation of the checked arithmetic. Performance tweaks without changing behavior and the rest of #185 can be carried out after the release of v0.9.0.
Closes #221