Returns the exponent of the magnitude of self's MSD. The result is the integer which is the exponent of the magnitude of the most significant digit of self (as though it were truncated to a single digit while maintaining the value of that digit and without limiting
(self, context=None)
| 3286 | return ans |
| 3287 | |
| 3288 | def logb(self, context=None): |
| 3289 | """ Returns the exponent of the magnitude of self's MSD. |
| 3290 | |
| 3291 | The result is the integer which is the exponent of the magnitude |
| 3292 | of the most significant digit of self (as though it were truncated |
| 3293 | to a single digit while maintaining the value of that digit and |
| 3294 | without limiting the resulting exponent). |
| 3295 | """ |
| 3296 | # logb(NaN) = NaN |
| 3297 | ans = self._check_nans(context=context) |
| 3298 | if ans: |
| 3299 | return ans |
| 3300 | |
| 3301 | if context is None: |
| 3302 | context = getcontext() |
| 3303 | |
| 3304 | # logb(+/-Inf) = +Inf |
| 3305 | if self._isinfinity(): |
| 3306 | return _Infinity |
| 3307 | |
| 3308 | # logb(0) = -Inf, DivisionByZero |
| 3309 | if not self: |
| 3310 | return context._raise_error(DivisionByZero, 'logb(0)', 1) |
| 3311 | |
| 3312 | # otherwise, simply return the adjusted exponent of self, as a |
| 3313 | # Decimal. Note that no attempt is made to fit the result |
| 3314 | # into the current context. |
| 3315 | ans = Decimal(self.adjusted()) |
| 3316 | return ans._fix(context) |
| 3317 | |
| 3318 | def _islogical(self): |
| 3319 | """Return True if self is a logical operand. |