Sets the rounding type. Sets the rounding type, and returns the current (previous) rounding type. Often used like: context = context.copy() # so you don't change the calling context # if an error occurs in the middle. rounding = context._set_roundin
(self, type)
| 4054 | return int(self.Emax - self.prec + 1) |
| 4055 | |
| 4056 | def _set_rounding(self, type): |
| 4057 | """Sets the rounding type. |
| 4058 | |
| 4059 | Sets the rounding type, and returns the current (previous) |
| 4060 | rounding type. Often used like: |
| 4061 | |
| 4062 | context = context.copy() |
| 4063 | # so you don't change the calling context |
| 4064 | # if an error occurs in the middle. |
| 4065 | rounding = context._set_rounding(ROUND_UP) |
| 4066 | val = self.__sub__(other, context=context) |
| 4067 | context._set_rounding(rounding) |
| 4068 | |
| 4069 | This will make it round up for that operation. |
| 4070 | """ |
| 4071 | rounding = self.rounding |
| 4072 | self.rounding = type |
| 4073 | return rounding |
| 4074 | |
| 4075 | def create_decimal(self, num='0'): |
| 4076 | """Creates a new Decimal instance but using self as context. |