Skip to content

Commit 57a1cca

Browse files
TotalVerbomus
authored andcommitted
Promote in _round_to_even
1 parent 316e759 commit 57a1cca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/FixedPointDecimals.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Round `quotient + remainder / divisor` to the nearest even integer, given that
115115
satisfied by the return value of `fldmod` in all cases, and the return value of
116116
`divrem` in cases where `divisor` is known to be positive.)
117117
"""
118-
function _round_to_even(quotient, remainder, divisor)
118+
function _round_to_even{T <: Integer}(quotient::T, remainder::T, divisor::T)
119119
halfdivisor = divisor >> 1
120120
if iseven(divisor) && remainder == halfdivisor
121121
ifelse(iseven(quotient), quotient, quotient + one(quotient))
@@ -125,6 +125,7 @@ function _round_to_even(quotient, remainder, divisor)
125125
quotient
126126
end
127127
end
128+
_round_to_even(q, r, d) = _round_to_even(promote(q, r, d)...)
128129

129130
# multiplication rounds to nearest even representation
130131
# TODO: can we use floating point to speed this up? after we build a

0 commit comments

Comments
 (0)