Returns to be "a - b * n", where n is the integer nearest the exact value of "x / b" (if two integers are equally near then the even one is chosen). If the result is equal to 0 then its sign will be the sign of a. This operation will fail under the same conditions a
(self, a, b)
| 5301 | return r |
| 5302 | |
| 5303 | def remainder_near(self, a, b): |
| 5304 | """Returns to be "a - b * n", where n is the integer nearest the exact |
| 5305 | value of "x / b" (if two integers are equally near then the even one |
| 5306 | is chosen). If the result is equal to 0 then its sign will be the |
| 5307 | sign of a. |
| 5308 | |
| 5309 | This operation will fail under the same conditions as integer division |
| 5310 | (that is, if integer division on the same two operands would fail, the |
| 5311 | remainder cannot be calculated). |
| 5312 | |
| 5313 | >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) |
| 5314 | Decimal('-0.9') |
| 5315 | >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) |
| 5316 | Decimal('-2') |
| 5317 | >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) |
| 5318 | Decimal('1') |
| 5319 | >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) |
| 5320 | Decimal('-1') |
| 5321 | >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) |
| 5322 | Decimal('0.2') |
| 5323 | >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) |
| 5324 | Decimal('0.1') |
| 5325 | >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) |
| 5326 | Decimal('-0.3') |
| 5327 | >>> ExtendedContext.remainder_near(3, 11) |
| 5328 | Decimal('3') |
| 5329 | >>> ExtendedContext.remainder_near(Decimal(3), 11) |
| 5330 | Decimal('3') |
| 5331 | >>> ExtendedContext.remainder_near(3, Decimal(11)) |
| 5332 | Decimal('3') |
| 5333 | """ |
| 5334 | a = _convert_other(a, raiseit=True) |
| 5335 | return a.remainder_near(b, context=self) |
| 5336 | |
| 5337 | def rotate(self, a, b): |
| 5338 | """Returns a rotated copy of a, b times. |