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