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
The current rounding mode of "mul"(*) for Fixed is RoundNearestTiesUp. (The comment "rounding up" is ambiguous, though.) In addition, the implementation with RoundDown is commented out. (The comment "truncation" is also ambiguous, though.)
*(x::Fixed{T,f}, y::Fixed{T,f}) where {T,f} =Fixed{T,f}((Base.widemul(x.i,y.i) + (one(widen(T)) << (f-1)))>>f,0)
However, considering the future addition of checked_mul, I think it would be better to change the rounding mode to the default (i.e. RoundNearest) for consistency.
On the other hand, I would also like to have the interfaces to implementations with other rounding modes, for speed. The problem is that there is no official interface that takes a rounding mode as an argument. The third argument of Base.*() collides with z in x * y * z (Of course, there are no arithmetic operations for RoundingMode, though).
The text was updated successfully, but these errors were encountered:
It might be a temporary option to add a function with a redundant name such as mul_with_rounding.
kimikage
changed the title
Changing rounding mode of mul for Fixed to RoundNearest
Changing rounding mode of "mul" (*) for Fixed to RoundNearestJan 25, 2020
The current rounding mode of "mul"(
*
) forFixed
isRoundNearestTiesUp
. (The comment "rounding up" is ambiguous, though.) In addition, the implementation withRoundDown
is commented out. (The comment "truncation" is also ambiguous, though.)FixedPointNumbers.jl/src/fixed.jl
Lines 76 to 79 in cb29336
However, considering the future addition of
checked_mul
, I think it would be better to change the rounding mode to the default (i.e.RoundNearest
) for consistency.On the other hand, I would also like to have the interfaces to implementations with other rounding modes, for speed. The problem is that there is no official interface that takes a rounding mode as an argument. The third argument of
Base.*()
collides withz
inx * y * z
(Of course, there are no arithmetic operations forRoundingMode
, though).The text was updated successfully, but these errors were encountered: