Returns a copy with the sign switched. Rounds, if it has reason.
(self, context=None)
| 1100 | return self.__str__(eng=True, context=context) |
| 1101 | |
| 1102 | def __neg__(self, context=None): |
| 1103 | """Returns a copy with the sign switched. |
| 1104 | |
| 1105 | Rounds, if it has reason. |
| 1106 | """ |
| 1107 | if self._is_special: |
| 1108 | ans = self._check_nans(context=context) |
| 1109 | if ans: |
| 1110 | return ans |
| 1111 | |
| 1112 | if context is None: |
| 1113 | context = getcontext() |
| 1114 | |
| 1115 | if not self and context.rounding != ROUND_FLOOR: |
| 1116 | # -Decimal('0') is Decimal('0'), not Decimal('-0'), except |
| 1117 | # in ROUND_FLOOR rounding mode. |
| 1118 | ans = self.copy_abs() |
| 1119 | else: |
| 1120 | ans = self.copy_negate() |
| 1121 | |
| 1122 | return ans._fix(context) |
| 1123 | |
| 1124 | def __pos__(self, context=None): |
| 1125 | """Returns a copy, unless it is a sNaN. |
no test coverage detected