Skip to content

Commit 192bb2f

Browse files
Output type is a float
1 parent f03443b commit 192bb2f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/fastpow.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,17 @@ const EXP2FT = (Float32(0x1.6a09e667f3bcdp-1),
5353
Float32(0x1.5ab07dd485429p+0))
5454

5555
"""
56-
fastpow(x::T, y::T) where {T} -> T
56+
fastpow(x::T, y::T) where {T} -> float(T)
5757
Trips through Float32 for performance.
5858
"""
5959
@inline function fastpow(x::T, y::T) where {T}
60+
outT = float(T)
6061
if iszero(x)
61-
return zero(T)
62+
return zero(outT)
6263
elseif isinf(x) && isinf(y)
63-
return convert(T,Inf)
64+
return convert(outT,Inf)
6465
else
65-
return convert(T,@fastmath exp2(convert(Float32, y) * fastlog2(convert(Float32, x))))
66+
return convert(outT,@fastmath exp2(convert(Float32, y) * fastlog2(convert(Float32, x))))
6667
end
6768
end
6869

0 commit comments

Comments
 (0)