-
-
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
Deprecate hex2num and num2hex #22088
Conversation
base/deprecated.jl
Outdated
|
||
@deprecate num2hex(x::Union{Float16,Float32,Float64}) = | ||
hex(reintepret(Unsigned, x), sizeof(x)*2) | ||
@deprecate num2hex(n::Integer) = hex(n, sizeof(n)*2) |
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.
at-deprecate doesn't need the =, right?
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.
Good point.
Instead of getting rid of those functions, I would prefer to transfer the functionality somewhere else. I didn't know them until few days ago, but I find
|
I agree that the functionality should still be easily accessible. Having to do |
I disagree: it's not clear exactly what the use case of this function is, and as discussed in #22031 it seems to encourage poor practices. |
|
I do not. Those are the names used in Matlab (not by coincidence I guess) and I feel that a change will only bring pain to Matlab users for no real gain. |
matlab doesn't have dispatch, so a lot of its API naming choices aren't that useful in terms of what we should do ( |
@rfourquet, if you just want to read the hex format of a floating-point number, why not use
If you really need it as a string you can always use I have yet to see a defensible practical usage of |
Yes you are right. Probably when I like to see the bits, in hex or binary form, I think "bits" rather than "reinterpret" in my head ;-) Still, |
We could always add a |
The question remains, what real application needs a hex form of a Float number as an actual string object that isn't served at least as well by As I mentioned in #22031, the only usage of |
I'm all for deprecating |
I don't see the value of complicating |
Adding 1.0 milestone since we should really get a decision on this. |
Triage is in favor. Let's rebase and merge. |
done. |
return reinterpret(Float64, parse(UInt64, s, 16)) | ||
end | ||
|
||
@deprecate num2hex(x::Union{Float16,Float32,Float64}) hex(reintepret(Unsigned, x), sizeof(x)*2) |
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.
reintepret
-> reinterpret
Introduce by #22088. Found by @fredrikekre
This needs an entry in NEWS. |
See #22031. I'm open to suggestions for the deprecation message for hex2num.