MCPcopy Index your code
hub / github.com/RustPython/RustPython / __neg__

Method __neg__

Lib/_pydecimal.py:1043–1063  ·  view source on GitHub ↗

Returns a copy with the sign switched. Rounds, if it has reason.

(self, context=None)

Source from the content-addressed store, hash-verified

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.

Callers 2

__abs__Method · 0.95
minusMethod · 0.45

Calls 5

_check_nansMethod · 0.95
copy_absMethod · 0.95
copy_negateMethod · 0.95
getcontextFunction · 0.85
_fixMethod · 0.80

Tested by

no test coverage detected