Skip to content
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

Round without overflow (Fix #59) #64

Merged
merged 1 commit into from
Mar 27, 2018
Merged

Conversation

jmkuhn
Copy link
Collaborator

@jmkuhn jmkuhn commented Mar 26, 2018

Fixes #59

julia> @sprintf("%e", realmin(Dec64))
"1.000000e-398"

julia> realmax(Dec64)
9.999999999999999e384

julia> @sprintf("%e", realmax(Dec64))
"1.000000e+385"

I uncommented the definitions for exponent and ldexp and renamed to exponent10 and ldexp10 to avoid confusion with Base exponent and ldexp. I like the name scale10 better than ldexp10. Do you have a preference on this? I am currently using these within DecFP.jl but not exporting them. I also defined tostring to wrap the library's to_string. I welcome a better name for this.

# Base.exponent(x::$BID) = nox(ccall(($(bidsym(w,"ilogb")), libbid), Cint, ($BID,), x))
# Base.ldexp(x::$BID, n::Integer) = nox(ccall(($(bidsym(w,"ldexp")), libbid), $BID, ($BID,Cint), x, n))
exponent10(x::$BID) = nox(ccall(($(bidsym(w,"ilogb")), libbid), Cint, ($BID,), x))
ldexp10(x::$BID, n::Integer) = nox(ccall(($(bidsym(w,"ldexp")), libbid), $BID, ($BID,Cint), x, n))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be exported?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I'll export these in a separate PR.

@stevengj stevengj merged commit dfddeec into JuliaMath:master Mar 27, 2018
@jmkuhn jmkuhn deleted the roundoverflow branch March 27, 2018 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants