File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1131,6 +1131,8 @@ julia> rem2pi(7pi/4, RoundDown)
11311131"""
11321132function rem2pi end
11331133function rem2pi (x:: Float64 , :: RoundingMode{:Nearest} )
1134+ isnan (x) && return NaN
1135+
11341136 abs (x) < pi && return x
11351137
11361138 n,y = rem_pio2_kernel (x)
@@ -1154,6 +1156,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Nearest})
11541156 end
11551157end
11561158function rem2pi (x:: Float64 , :: RoundingMode{:ToZero} )
1159+ isnan (x) && return NaN
1160+
11571161 ax = abs (x)
11581162 ax <= 2 * Float64 (pi ,RoundDown) && return x
11591163
@@ -1179,6 +1183,8 @@ function rem2pi(x::Float64, ::RoundingMode{:ToZero})
11791183 copysign (z,x)
11801184end
11811185function rem2pi (x:: Float64 , :: RoundingMode{:Down} )
1186+ isnan (x) && return NaN
1187+
11821188 if x < pi4o2_h
11831189 if x >= 0
11841190 return x
@@ -1208,6 +1214,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Down})
12081214 end
12091215end
12101216function rem2pi (x:: Float64 , :: RoundingMode{:Up} )
1217+ isnan (x) && return NaN
1218+
12111219 if x > - pi4o2_h
12121220 if x <= 0
12131221 return x
Original file line number Diff line number Diff line change @@ -2611,6 +2611,13 @@ end
26112611 @test rem2pi (T (- 8 ), RoundUp) ≈ - 8 + 2pi
26122612end
26132613
2614+ @testset " PR #36420 $T " for T in (Float16, Float32, Float64)
2615+ @test rem2pi (T (NaN ), RoundToZero) === T (NaN )
2616+ @test rem2pi (T (NaN ), RoundNearest) === T (NaN )
2617+ @test rem2pi (T (NaN ), RoundDown) === T (NaN )
2618+ @test rem2pi (T (NaN ), RoundUp) === T (NaN )
2619+ end
2620+
26142621import Base.^
26152622struct PR20530; end
26162623struct PR20889; x; end
You can’t perform that action at this time.
0 commit comments