Open
Conversation
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.
PR that was mentioned earlier today..
I went ahead and combined the
checked_*methods into a single trait,CheckedMaths, which seemed "cleaner" to me. If you do not like this, I have no problem changing it back to one trait perchecked_*method.Click to view
CheckedMathstraitSeparate Concern
TLDR
Click to view TLDR demo
Extended Explanation
Also, I noticed the existing implementation of
DivAssigncauses issues withtrunc_div.For example, notice the last digit (3 vs 4):
I could be wrong, but I believe this is because the
DivAssignimplementation promotes to float prior to dividing, which causes thei128::MAXto lose some precision, thus producing an incorrect answer.Implementation of
DivAssignfor reference:FYI - this is the new implementation, but the same issue exists in the old implementation as well - this change is not what caused the issue.
Click to view DivAssign
Changing the implementation to the code below solves the issue described above.
AddAssign/SubAssign/MulAssign/RemAssignimplementationsClick to view DivAssign fix
Thoughts?