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 @@ -1239,6 +1239,8 @@ julia> rem2pi(7pi/4, RoundDown)
12391239"""
12401240function rem2pi end
12411241function rem2pi (x:: Float64 , :: RoundingMode{:Nearest} )
1242+ isnan (x) && return NaN
1243+
12421244 abs (x) < pi && return x
12431245
12441246 n,y = rem_pio2_kernel (x)
@@ -1262,6 +1264,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Nearest})
12621264 end
12631265end
12641266function rem2pi (x:: Float64 , :: RoundingMode{:ToZero} )
1267+ isnan (x) && return NaN
1268+
12651269 ax = abs (x)
12661270 ax <= 2 * Float64 (pi ,RoundDown) && return x
12671271
@@ -1287,6 +1291,8 @@ function rem2pi(x::Float64, ::RoundingMode{:ToZero})
12871291 copysign (z,x)
12881292end
12891293function rem2pi (x:: Float64 , :: RoundingMode{:Down} )
1294+ isnan (x) && return NaN
1295+
12901296 if x < pi4o2_h
12911297 if x >= 0
12921298 return x
@@ -1316,6 +1322,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Down})
13161322 end
13171323end
13181324function rem2pi (x:: Float64 , :: RoundingMode{:Up} )
1325+ isnan (x) && return NaN
1326+
13191327 if x > - pi4o2_h
13201328 if x <= 0
13211329 return x
Original file line number Diff line number Diff line change @@ -2675,6 +2675,13 @@ end
26752675 @test rem2pi (T (- 8 ), RoundUp) ≈ - 8 + 2pi
26762676end
26772677
2678+ @testset " PR #36420 $T " for T in (Float16, Float32, Float64)
2679+ @test rem2pi (T (NaN ), RoundToZero) === T (NaN )
2680+ @test rem2pi (T (NaN ), RoundNearest) === T (NaN )
2681+ @test rem2pi (T (NaN ), RoundDown) === T (NaN )
2682+ @test rem2pi (T (NaN ), RoundUp) === T (NaN )
2683+ end
2684+
26782685import Base.^
26792686struct PR20530; end
26802687struct PR20889; x; end
You can’t perform that action at this time.
0 commit comments