Skip to content

Commit 7756238

Browse files
committed
Further reduce BigInts by skipping a rem() in iseven
1 parent a1c1711 commit 7756238

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/FixedPointDecimals.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ function _round_to_nearest(quotient::T,
175175
divisor::T,
176176
::RoundingMode{M}=RoundNearest) where {T <: Integer, M}
177177
halfdivisor = divisor >> 1
178-
if iseven(divisor) && remainder == halfdivisor
178+
# PERF Note: Only need the last bit to check iseven, and default iseven(Int256)
179+
# allocates, so we truncate first.
180+
if iseven((divisor % Int8)) && remainder == halfdivisor
179181
# `:NearestTiesAway` will tie away from zero, e.g. -8.5 ->
180182
# -9. `:NearestTiesUp` will always ties towards positive
181183
# infinity. `:Nearest` will tie towards the nearest even

0 commit comments

Comments
 (0)