MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __neg__

Method __neg__

tools/python-3.11.9-amd64/Lib/_pydecimal.py:1102–1122  ·  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

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.

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