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

Method logb

tools/python-3.11.9-amd64/Lib/_pydecimal.py:3333–3361  ·  view source on GitHub ↗

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 limi

(self, context=None)

Source from the content-addressed store, hash-verified

3331 return ans
3332
3333 def logb(self, context=None):
3334 """ Returns the exponent of the magnitude of self's MSD.
3335
3336 The result is the integer which is the exponent of the magnitude
3337 of the most significant digit of self (as though it were truncated
3338 to a single digit while maintaining the value of that digit and
3339 without limiting the resulting exponent).
3340 """
3341 # logb(NaN) = NaN
3342 ans = self._check_nans(context=context)
3343 if ans:
3344 return ans
3345
3346 if context is None:
3347 context = getcontext()
3348
3349 # logb(+/-Inf) = +Inf
3350 if self._isinfinity():
3351 return _Infinity
3352
3353 # logb(0) = -Inf, DivisionByZero
3354 if not self:
3355 return context._raise_error(DivisionByZero, 'logb(0)', 1)
3356
3357 # otherwise, simply return the adjusted exponent of self, as a
3358 # Decimal. Note that no attempt is made to fit the result
3359 # into the current context.
3360 ans = Decimal(self.adjusted())
3361 return ans._fix(context)
3362
3363 def _islogical(self):
3364 """Return True if self is a logical operand.

Callers 1

logbMethod · 0.45

Calls 7

_check_nansMethod · 0.95
_isinfinityMethod · 0.95
adjustedMethod · 0.95
_fixMethod · 0.95
getcontextFunction · 0.85
DecimalClass · 0.85
_raise_errorMethod · 0.80

Tested by

no test coverage detected