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.
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
check for
typemin(T)
in denominator of rational #32572check for
typemin(T)
in denominator of rational #32572Changes from 3 commits
c6df5aa
1b275d7
f3dcb6e
b441119
6b299e6
e0ce76c
418da48
afe59bf
52f1bd8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, in my previous review I was just looking at the
typemin
stuff, but actually I think this error logic here is not appropriate in general. A type could have atypemin
without the current definition being an error. The real problem occurs whentypemin(T) == -typemin(T)
(which is typically true for bit types which use 2-complement arithmetic). So I suggest instead moving the error checking in the below line, something like:T <: Signed && signbit(den) && signbit(-den) && throw(...)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense. So just delete all the
hastypemin
stuff?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think, this check is very good, because it requires construction of
-den
, which is expensive in the case ofBigInt
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be constructed only when necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @KlausC suggested, this constructs unnecessarily
-den
once more than necessary. You can rearrange the code to fix that, e.g.