Lines Matching refs:other

81     def __add__(self, other):
83 if isint(other):
84 other = Rat(other)
85 if isRat(other):
86 return Rat(self.__num*other.__den + other.__num*self.__den,
87 self.__den*other.__den)
88 if isnum(other):
89 return float(self) + other
94 def __sub__(self, other):
96 if isint(other):
97 other = Rat(other)
98 if isRat(other):
99 return Rat(self.__num*other.__den - other.__num*self.__den,
100 self.__den*other.__den)
101 if isnum(other):
102 return float(self) - other
105 def __rsub__(self, other):
107 if isint(other):
108 other = Rat(other)
109 if isRat(other):
110 return Rat(other.__num*self.__den - self.__num*other.__den,
111 self.__den*other.__den)
112 if isnum(other):
113 return other - float(self)
116 def __mul__(self, other):
118 if isRat(other):
119 return Rat(self.__num*other.__num, self.__den*other.__den)
120 if isint(other):
121 return Rat(self.__num*other, self.__den)
122 if isnum(other):
123 return float(self)*other
128 def __truediv__(self, other):
130 if isRat(other):
131 return Rat(self.__num*other.__den, self.__den*other.__num)
132 if isint(other):
133 return Rat(self.__num, self.__den*other)
134 if isnum(other):
135 return float(self) / other
138 def __rtruediv__(self, other):
140 if isRat(other):
141 return Rat(other.__num*self.__den, other.__den*self.__num)
142 if isint(other):
143 return Rat(other*self.__den, self.__num)
144 if isnum(other):
145 return other / float(self)
148 def __floordiv__(self, other):
150 if isint(other):
151 other = Rat(other)
152 elif not isRat(other):
154 x = self/other
157 def __rfloordiv__(self, other):
159 x = other/self
162 def __divmod__(self, other):
164 if isint(other):
165 other = Rat(other)
166 elif not isRat(other):
168 x = self//other
169 return (x, self - other * x)
171 def __rdivmod__(self, other):
173 if isint(other):
174 other = Rat(other)
175 elif not isRat(other):
177 return divmod(other, self)
179 def __mod__(self, other):
181 return divmod(self, other)[1]
183 def __rmod__(self, other):
185 return divmod(other, self)[1]
187 def __eq__(self, other):
189 if isint(other):
190 return self.__den == 1 and self.__num == other
191 if isRat(other):
192 return self.__num == other.__num and self.__den == other.__den
193 if isnum(other):
194 return float(self) == other
325 def __eq__(self, other):
328 def __le__(self, other):
331 def __ge__(self, other):
336 def __eq__(self, other):
339 def __le__(self, other):
342 def __ge__(self, other):
347 def __eq__(self, other):
350 def __le__(self, other):
353 def __ge__(self, other):
359 def __eq__(self, other):
362 def __le__(self, other):
365 def __ge__(self, other):
392 def __eq__(self, other):
412 def __eq__(self, other):