MCPcopy Index your code
hub / github.com/python/cpython / __pos__

Method __pos__

Lib/_pydecimal.py:1068–1087  ·  view source on GitHub ↗

Returns a copy, unless it is a sNaN. Rounds the number (if more than precision digits)

(self, context=None)

Source from the content-addressed store, hash-verified

1066 return ans._fix(context)
1067
1068 def __pos__(self, context=None):
1069 """Returns a copy, unless it is a sNaN.
1070
1071 Rounds the number (if more than precision digits)
1072 """
1073 if self._is_special:
1074 ans = self._check_nans(context=context)
1075 if ans:
1076 return ans
1077
1078 if context is None:
1079 context = getcontext()
1080
1081 if not self and context.rounding != ROUND_FLOOR:
1082 # + (-0) = 0, except in ROUND_FLOOR rounding mode.
1083 ans = self.copy_abs()
1084 else:
1085 ans = Decimal(self)
1086
1087 return ans._fix(context)
1088
1089 def __abs__(self, round=True, context=None):
1090 """Returns the absolute value of self.

Callers 2

__abs__Method · 0.95
plusMethod · 0.45

Calls 5

_check_nansMethod · 0.95
copy_absMethod · 0.95
_fixMethod · 0.95
getcontextFunction · 0.85
DecimalClass · 0.85

Tested by

no test coverage detected