Returns a copy with the sign switched. Rounds, if it has reason.
(self, context=None)
| 1044 | return self.__str__(eng=True, context=context) |
| 1045 | |
| 1046 | def __neg__(self, context=None): |
| 1047 | """Returns a copy with the sign switched. |
| 1048 | |
| 1049 | Rounds, if it has reason. |
| 1050 | """ |
| 1051 | if self._is_special: |
| 1052 | ans = self._check_nans(context=context) |
| 1053 | if ans: |
| 1054 | return ans |
| 1055 | |
| 1056 | if context is None: |
| 1057 | context = getcontext() |
| 1058 | |
| 1059 | if not self and context.rounding != ROUND_FLOOR: |
| 1060 | # -Decimal('0') is Decimal('0'), not Decimal('-0'), except |
| 1061 | # in ROUND_FLOOR rounding mode. |
| 1062 | ans = self.copy_abs() |
| 1063 | else: |
| 1064 | ans = self.copy_negate() |
| 1065 | |
| 1066 | return ans._fix(context) |
| 1067 | |
| 1068 | def __pos__(self, context=None): |
| 1069 | """Returns a copy, unless it is a sNaN. |
no test coverage detected