Decimal division in a specified context. >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) Decimal('0.333333333') >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) Decimal('0.666666667') >>> ExtendedContext.divide(Decimal('5'), Decimal('2'))
(self, a, b)
| 4337 | return a.copy_sign(b) |
| 4338 | |
| 4339 | def divide(self, a, b): |
| 4340 | """Decimal division in a specified context. |
| 4341 | |
| 4342 | >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) |
| 4343 | Decimal('0.333333333') |
| 4344 | >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) |
| 4345 | Decimal('0.666666667') |
| 4346 | >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) |
| 4347 | Decimal('2.5') |
| 4348 | >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) |
| 4349 | Decimal('0.1') |
| 4350 | >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) |
| 4351 | Decimal('1') |
| 4352 | >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) |
| 4353 | Decimal('4.00') |
| 4354 | >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) |
| 4355 | Decimal('1.20') |
| 4356 | >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) |
| 4357 | Decimal('10') |
| 4358 | >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) |
| 4359 | Decimal('1000') |
| 4360 | >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) |
| 4361 | Decimal('1.20E+6') |
| 4362 | >>> ExtendedContext.divide(5, 5) |
| 4363 | Decimal('1') |
| 4364 | >>> ExtendedContext.divide(Decimal(5), 5) |
| 4365 | Decimal('1') |
| 4366 | >>> ExtendedContext.divide(5, Decimal(5)) |
| 4367 | Decimal('1') |
| 4368 | """ |
| 4369 | a = _convert_other(a, raiseit=True) |
| 4370 | r = a.__truediv__(b, context=self) |
| 4371 | if r is NotImplemented: |
| 4372 | raise TypeError("Unable to convert %s to Decimal" % b) |
| 4373 | else: |
| 4374 | return r |
| 4375 | |
| 4376 | def divide_int(self, a, b): |
| 4377 | """Divides two numbers and returns the integer part of the result. |