-
Notifications
You must be signed in to change notification settings - Fork 33
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
exponent
and significand
functions
#148
Comments
Turns out there's a better function for this. Which is defined & runs without error. But returns a julia> frexp(123.4)
(0.9640625, 7)
julia> frexp(Double64(123.4))
((0.9640625, 7), (0.0, 0))
julia> @which frexp(Double64(123.4))
frexp(x::DoubleFloat{T}) where T<:Union{Float16, Float32, Float64} in DoubleFloats at /Users/me/.julia/packages/DoubleFloats/h3HrU/src/math/prearith/prearith.jl:44
help?> frexp
search: frexp firstindex
frexp(val)
Return (x,exp) such that x has a magnitude in the interval [1/2, 1) or 0, and val is equal to x
\times 2^{exp}. |
frexp and ldexp are dual functions in this sense The reason that exponent exploded is seen by trying |
I was surprised by But I wonder if the version returning two tuples, for people who are sure they have a DoubleFloat, should have another name, rather than extending |
I see what you mean. It could work as you explain with a helper function available to map the 2-tuple form into two 2-tuples for more exacting work. ... |
The exponent function gives an error on Double64, and does not seem to be covered by tests: https://app.codecov.io/gh/JuliaMath/DoubleFloats.jl/blob/master/src/math/prearith/prearith.jl
I think it's calling
exponent(0.0)
, to make a tuple, like that made bysignificand
:More generally, is this the right thing to return? I would expect the results to obey
x == significand(x) * 2^exponent(x)
, but this isn't possible if they return tuples. Maybesignificand
should return another Double64? If these tuples are needed, they could be internal functions, not overloads of Base.The context is that it would be nice if JuliaStats/LogExpFunctions.jl#48 could work on AbstractFloat.
The text was updated successfully, but these errors were encountered: