-
Notifications
You must be signed in to change notification settings - Fork 33
Adding rounding functions for Fixed
#153
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
Comments
BTW, I think the current implementation has an overflow problem. ( FixedPointNumbers.jl/src/normed.jl Lines 261 to 266 in 7ad0f0c
The method using function round(x::Normed{T,f}) where {T,f}
d, r = divrem(reinterpret(x), rawone(x))
return Normed{T,f}((d + r>>(f-1))*rawone(x), 0)
end |
julia> round(typemax(N0f64)) # on 64-bit version
ERROR: InexactError: check_top_bit(Int64, -9223372036854775808)
julia> ceil(typemax(N1f7)) # wraparound
0.984N1f7
|
This is off-topic, but not only |
Add rounding functions for `Fixed` (Fixes #153)
As I mentioned in #139, there are no rounding functions for
Fixed
.An important difference between
Normed
andFixed
is thatNormed
has no tie (or half) numbers, butFixed
has.So, I also think it is a good idea to support the 2nd argument (i.e.
RoundingMode
) explicitly.The text was updated successfully, but these errors were encountered: