You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I mentioned in #139, there are no rounding functions for Fixed.
julia>round(0.502N0f8)
1.0N0f8
julia>round(0.500Q0f7)
ERROR: MethodError: no method matching round(::Fixed{Int8,7}, ::RoundingMode{:Nearest})
An important difference between Normed and Fixed is that Normed has no tie (or half) numbers, but Fixed has.
So, I also think it is a good idea to support the 2nd argument (i.e. RoundingMode) explicitly.
The method using divrem proposed in the PR #143 will probably solve the overflow problem. (I guess it cannot handle the signedNormed correctly, though.)
functionround(x::Normed{T,f}) where {T,f}
d, r =divrem(reinterpret(x), rawone(x))
returnNormed{T,f}((d + r>>(f-1))*rawone(x), 0)
end
Activity
kimikage commentedon Dec 24, 2019
BTW, I think the current implementation has an overflow problem. (
1is aInt64orInt32number.)FixedPointNumbers.jl/src/normed.jl
Lines 261 to 266 in 7ad0f0c
The method using
divremproposed in the PR #143 will probably solve the overflow problem. (I guess it cannot handle the signedNormedcorrectly, though.)kimikage commentedon Dec 25, 2019
testtruncis not so powerful even though it spends a lot of time.kimikage commentedon Jan 11, 2020
This is off-topic, but not only
rembut alsodivis going to accept a rounding mode in Julia v1.4.Merge pull request #158 from kimikage/round