Returns the absolute value of self. If the keyword argument 'round' is false, do not round. The expression self.__abs__(round=False) is equivalent to self.copy_abs().
(self, round=True, context=None)
| 1084 | return ans._fix(context) |
| 1085 | |
| 1086 | def __abs__(self, round=True, context=None): |
| 1087 | """Returns the absolute value of self. |
| 1088 | |
| 1089 | If the keyword argument 'round' is false, do not round. The |
| 1090 | expression self.__abs__(round=False) is equivalent to |
| 1091 | self.copy_abs(). |
| 1092 | """ |
| 1093 | if not round: |
| 1094 | return self.copy_abs() |
| 1095 | |
| 1096 | if self._is_special: |
| 1097 | ans = self._check_nans(context=context) |
| 1098 | if ans: |
| 1099 | return ans |
| 1100 | |
| 1101 | if self._sign: |
| 1102 | ans = self.__neg__(context=context) |
| 1103 | else: |
| 1104 | ans = self.__pos__(context=context) |
| 1105 | |
| 1106 | return ans |
| 1107 | |
| 1108 | def __add__(self, other, context=None): |
| 1109 | """Returns self + other. |
no test coverage detected