File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -989,6 +989,8 @@ julia> rem2pi(7pi/4, RoundDown)
989989""" 
990990function  rem2pi end 
991991function  rem2pi (x:: Float64 , :: RoundingMode{:Nearest} )
992+     isfinite (x) ||  return  NaN 
993+ 
992994    abs (x) <  pi  &&  return  x
993995
994996    n,y =  rem_pio2_kernel (x)
@@ -1012,6 +1014,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Nearest})
10121014    end 
10131015end 
10141016function  rem2pi (x:: Float64 , :: RoundingMode{:ToZero} )
1017+     isfinite (x) ||  return  NaN 
1018+ 
10151019    ax =  abs (x)
10161020    ax <=  2 * Float64 (pi ,RoundDown) &&  return  x
10171021
@@ -1037,6 +1041,8 @@ function rem2pi(x::Float64, ::RoundingMode{:ToZero})
10371041    copysign (z,x)
10381042end 
10391043function  rem2pi (x:: Float64 , :: RoundingMode{:Down} )
1044+     isfinite (x) ||  return  NaN 
1045+ 
10401046    if  x <  pi4o2_h
10411047        if  x >=  0 
10421048            return  x
@@ -1066,6 +1072,8 @@ function rem2pi(x::Float64, ::RoundingMode{:Down})
10661072    end 
10671073end 
10681074function  rem2pi (x:: Float64 , :: RoundingMode{:Up} )
1075+     isfinite (x) ||  return  NaN 
1076+ 
10691077    if  x >  - pi4o2_h
10701078        if  x <=  0 
10711079            return  x
Original file line number Diff line number Diff line change @@ -2530,6 +2530,15 @@ end
25302530    @test  rem2pi (T (- 8 ), RoundUp)      ≈  - 8 + 2pi 
25312531end 
25322532
2533+ @testset  " PR #36420 $T " for  T in  (Float16, Float32, Float64)
2534+     for  r in  (RoundToZero, RoundNearest, RoundDown, RoundUp)
2535+         for  x in  (Inf , - Inf , NaN , - NaN )
2536+             @test  isnan (rem2pi (T (x), r))
2537+             @test  rem2pi (T (x), r) isa  T
2538+         end 
2539+     end 
2540+ end 
2541+ 
25332542import  Base.^ 
25342543struct  PR20530; end 
25352544struct  PR20889; x; end 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments