Skip to content

Commit 848dfc5

Browse files
committed
Avoid checking which rounding function is called at runtime
1 parent d1b3451 commit 848dfc5

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

base/floatfuncs.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,9 @@ for f in (:round, :ceil, :floor, :trunc)
153153
if digits > 0
154154
return x
155155
elseif x > 0
156-
if ceil == $f
157-
return convert(eltype(x), Inf)
158-
end
159-
return zero(x)
156+
return $(:ceil == f ? :(convert(eltype(x), Inf)) : :(zero(x)))
160157
elseif x < 0
161-
if floor == $f
162-
return -convert(eltype(x), Inf)
163-
end
164-
return -zero(x)
158+
return $(:floor == f ? :(-convert(eltype(x), Inf)) : :(-zero(x)))
165159
else
166160
return x
167161
end

0 commit comments

Comments
 (0)