-
Notifications
You must be signed in to change notification settings - Fork 23
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
Normalization and rounding #88
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #88 +/- ##
===========================================
+ Coverage 99.69% 100.00% +0.30%
===========================================
Files 11 11
Lines 330 327 -3
===========================================
- Hits 329 327 -2
+ Misses 1 0 -1 ☔ View full report in Codecov by Sentry. |
5b8bbb0
to
fa1e39e
Compare
The PR replaces `round` and `normalize`. Fixes JuliaMath#27 Fixes JuliaMath#36 Fixes JuliaMath#39 Fixes JuliaMath#50
@ViralBShah @oscardssmith I would appreciate your input here. My intention is to support the interface round([T,] x, [r::RoundingMode])
round(x, [r::RoundingMode]; digits::Integer=0)
round(x, [r::RoundingMode]; sigdigits::Integer) Defining It is also not enough to define only one method Base.round(x::Decimal, r::RoundingMode; digits, sigdigits) because then, e.g., So I am generating 6 methods for 6 rounding modes: for r in (RoundingMode{:Up},
RoundingMode{:Down},
RoundingMode{:FromZero},
RoundingMode{:Nearest},
RoundingMode{:NearestTiesAway},
RoundingMode{:ToZero})
@eval function Base.round(x::Decimal, r::$r;
digits::Union{Nothing, Integer}=nothing,
sigdigits::Union{Nothing, Integer}=nothing)
return _round(x, r, digits, sigdigits)
end
end It passes tests but I am not sure how good/bad this is. I asked on Discourse, but haven't received a definite answer so far. |
I don't have input here, but I would suggest looking at DecFP.jl (in case they address it there). |
I looked at DecFP.jl and tried to copy their approach, but it did not work for DecFP only defines methods of the form I implemented the same methods for Decimals, but when I tried |
The PR replaces
round
andnormalize
.Fixes #27:
Fixes #36 (the confusing argument will be gone)
Fixes #39 (the confusing argument will be gone)
Fixes #50: