Skip to content

Commit 8f04cea

Browse files
committed
fix
1 parent bd34e65 commit 8f04cea

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

base/math.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ end
11871187
yint = unsafe_trunc(Int32, y) # This is actually safe since julia freezes the result
11881188
yisint = y == yint
11891189
if yisint
1190-
yint == 0 && return 1.0
1190+
yint == 0 && return one(T)
11911191
use_power_by_squaring(yint) && return pow_body(x, yint)
11921192
end
11931193
s = 1

test/math.jl

+1
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ end
14431443
Float32=>[.51, .51, .51, 2.0, 1.5],
14441444
Float64=>[.55, 0.8, 1.5, 2.0, 1.5])
14451445
for T in (Float16, Float32, Float64)
1446+
@inferred T T(1.1)^T(1.1) #test that we always return the right type
14461447
for x in (0.0, -0.0, 1.0, 10.0, 2.0, Inf, NaN, -Inf, -NaN)
14471448
for y in (0.0, -0.0, 1.0, -3.0,-10.0 , Inf, NaN, -Inf, -NaN)
14481449
got, expected = T(x)^T(y), T(big(x)^T(y))

0 commit comments

Comments
 (0)