-
Notifications
You must be signed in to change notification settings - Fork 22
Fix printf formatting #48
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
Conversation
src/DecFP.jl
Outdated
@@ -102,11 +103,80 @@ for w in (32,64,128) | |||
return xchk(x, InexactError, :parse, $BID, s) | |||
end | |||
|
|||
$BID(x::AbstractString) = parse($BID, x) |
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'm not sure about this. Base doesn't define Int("3")
, after all.
If this is just defined for the tests, we could define this method in runtests.jl
.
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.
Base does define BigFloat("1").
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.
Oh, ok.
This is great, thanks for working on this. Can we change the default |
I'll work on |
The output from |
@@ -79,6 +79,14 @@ function isnanstr(s::AbstractString) | |||
return true | |||
end | |||
|
|||
function Base.show(io::IO, x::DecimalFloatingPoint) | |||
s = @sprintf("%g", x) | |||
if ismatch(r"^-?\d+$", s) |
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.
Wouldn't '.' ∉ s
be sufficient?
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.
Using my current implementation,
julia> show(d64"1e10")
1e+10
Replacing ismatch
with ∉ would produce 1e+10.0
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.
Okay.
LGTM. The CI failures on 0.7 (nightly) are unrelated. |
Fixes Issue #26. Implements %f %F %e %E %g %G. Doesn't implement %a/%A.
I also added the Dec*(x::AbstractString) constructor to simplify writing the tests.