Creates a new Decimal instance but using self as context. This method implements the to-number operation of the IBM Decimal specification.
(self, num='0')
| 4073 | return rounding |
| 4074 | |
| 4075 | def create_decimal(self, num='0'): |
| 4076 | """Creates a new Decimal instance but using self as context. |
| 4077 | |
| 4078 | This method implements the to-number operation of the |
| 4079 | IBM Decimal specification.""" |
| 4080 | |
| 4081 | if isinstance(num, str) and (num != num.strip() or '_' in num): |
| 4082 | return self._raise_error(ConversionSyntax, |
| 4083 | "trailing or leading whitespace and " |
| 4084 | "underscores are not permitted.") |
| 4085 | |
| 4086 | d = Decimal(num, context=self) |
| 4087 | if d._isnan() and len(d._int) > self.prec - self.clamp: |
| 4088 | return self._raise_error(ConversionSyntax, |
| 4089 | "diagnostic info too long in NaN") |
| 4090 | return d._fix(self) |
| 4091 | |
| 4092 | def create_decimal_from_float(self, f): |
| 4093 | """Creates a new Decimal instance from a float but rounding using self |