@@ -97,25 +97,29 @@ for (jlop, hloop) in (
97
97
(:(Base. mod), :remainder ),
98
98
(:(Base. rem), :remainder ),
99
99
)
100
- @eval begin
101
- function $ (jlop)(
102
- @nospecialize (lhs :: TracedRNumber {T}), @nospecialize (rhs :: TracedRNumber{T} )
103
- ) where {T}
104
- return Ops. $ (hloop)(lhs, rhs)
105
- end
100
+ @eval function $ (jlop)(
101
+ @nospecialize (lhs :: TracedRNumber{T} ), @nospecialize (rhs :: TracedRNumber{T} )
102
+ ) where {T}
103
+ return Ops. $ (hloop)(lhs, rhs)
104
+ end
105
+ end
106
106
107
- function $ (jlop) (
108
- @nospecialize (lhs:: TracedRNumber{T} ), @nospecialize (rhs:: Number )
109
- ) where {T}
110
- return Ops.$ (hloop) (lhs, TracedUtils. promote_to (TracedRNumber{T}, rhs))
111
- end
107
+ function Base . rem (
108
+ @nospecialize (lhs:: TracedRNumber{T} ), @nospecialize (rhs:: Number )
109
+ ) where {T}
110
+ return Ops. remainder (lhs, TracedUtils. promote_to (TracedRNumber{T}, rhs))
111
+ end
112
112
113
- function $ (jlop)(
114
- @nospecialize (lhs:: Number ), @nospecialize (rhs:: TracedRNumber{T} )
115
- ) where {T}
116
- return Ops.$ (hloop)(TracedUtils. promote_to (TracedRNumber{T}, lhs), rhs)
117
- end
118
- end
113
+ function Base. rem (
114
+ @nospecialize (lhs:: Number ), @nospecialize (rhs:: TracedRNumber{T} )
115
+ ) where {T}
116
+ return Ops. remainder (TracedUtils. promote_to (TracedRNumber{T}, lhs), rhs)
117
+ end
118
+
119
+
120
+ function Base. mod (@nospecialize (x:: Reactant.TracedRNumber{T} ), @nospecialize (y:: Reactant.TracedRNumber{T} )) where {T}
121
+ r = rem (x, y)
122
+ return ifelse (r == 0 , copysign (r,y), ifelse ((r > 0 ) ⊻ (y > 0 ), r + y, r))
119
123
end
120
124
121
125
function Base. div (@nospecialize (lhs:: TracedRNumber{T} ), rhs) where {T<: Integer }
0 commit comments