-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
change widen
to strict 2x widening
#28045
change widen
to strict 2x widening
#28045
Conversation
Given the relatively small amount of code churn in the tests, I don't think this should be too breaking. |
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.
LGTM. It's a good sign that the only things that need to change seem to be explicit tests for the return type. Also, you gotta love how easy this kind of change is in Julia 😁
Maybe explain this in the docs? |
There's an item about |
I didn't know how to update NEWS without an issue/PR number. Should I include the NEWS.md changes as another commit here now that we know it's #28045 ? |
Yes, it's fine to add as another commit. We can squash it all on merge. |
OK, what doc changes do people suggest? I think the current docstring is fairly clear. Do we really need to change it? (ref https://docs.julialang.org/en/latest/base/base/#Base.widen) |
It is fairly clear and this is still in line with it. Might be good to explicitly state that for fixed-size integer types less than 128-bits widen doubles the bit size since that's now the rule. |
Something like:
|
Sorry, I pressed the wrong button. |
OK, I made changes to |
I was actually puzzled as to why the return types weren't being tested in the first place (except for |
base/operators.jl
Outdated
@@ -778,7 +778,10 @@ fldmod1(x, y) = (fld1(x, y), mod1(x, y)) | |||
|
|||
If `x` is a type, return a "larger" type, defined so that arithmetic operations | |||
`+` and `-` are guaranteed not to overflow nor lose precision for any combination | |||
of values that type `x` can hold. | |||
of values that type `x` can hold. |
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.
Trailing whitespace on this line and the next.
That's a weird test in numbers.jl. Why is that there? |
It doesn’t look like the appveyor failure is related. Could someone please confirm? |
Yep, looks like a problem with httpbin.org which happens quite a bit lately. |
The Win32 failure is indeed the |
Eh, why wait. Just went for it. |
Thank you all for the guidance! This was an easy PR. |
Per #14407 (comment) et seq., change the behavior of
widen()
as follows:for all types with bit size
n
,widen()
will produce a similarly-signed type with bit size2n
regardless of underlying word size / architecture. This changes the following:widen()
UInt8
UInt
UInt16
UInt16
UInt
UInt32
Int8
Int
Int16
Int16
Int
Int32
In addition, added explicit type tests.