-
-
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
check overflow in hex2num (fix #22031) #22039
Conversation
I need here a function, say |
base/intfuncs.jl
Outdated
|
||
julia> num2hex(2.2) | ||
"400199999999999a" | ||
|
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.
excess blank line here
I think "a hexadecimal" is more common than "an hexadecimal"
base/intfuncs.jl
Outdated
|
||
An hexadecimal string of the binary representation of a number. | ||
See also the [`bits`](@ref) function, which is similar but gives | ||
a binary string, and [`hex2num`] which does the opposite conversion. |
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.
[`hex2num`](@ref)
maybe.
base/essentials.jl
Outdated
unsigned without checking for negative values. | ||
See also [`signed`](@ref). | ||
|
||
unsigned(T::Type) -> UnsignedType |
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.
should this be a separate docstring for the separate signature?
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 know, but will do.
base/intfuncs.jl
Outdated
# this construction is not available when put in int.jl and running in Core | ||
for (S,U,F) in zip(BitSigned_types, BitUnsigned_types, | ||
(nothing, Float16, Float32, Float64, nothing)) | ||
@eval begin |
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.
the body of this for loop is indented one level too deep
Thanks @tkelman and @fredrikekre, comments addressed. |
Given #22088, is this still relevant? |
It looks like this would still be useful if the hex2num-specific parts were removed. |
Replaced by #22203 |
This also creates
hex2num(::Type, str)
to get a type-stable function, and fix (what I think to be) a bug, wherenum2hex(-1) == "-0000000000000001"
instead of "ffffffffffffffff", i.e.num2hex
is supposed to give the bit-pattern in hex form (similar tobits
).Edit: this is independant of the question on whether
hex2num
should be moved toparse
...