MCPcopy Index your code
hub / github.com/RustPython/RustPython / logb

Method logb

Lib/_pydecimal.py:3285–3313  ·  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 limiting

(self, context=None)

Source from the content-addressed store, hash-verified

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

Callers 4

test_none_argsMethod · 0.95
logbMethod · 0.45
test_named_parametersMethod · 0.45
test_implicit_contextMethod · 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 3

test_none_argsMethod · 0.76
test_named_parametersMethod · 0.36
test_implicit_contextMethod · 0.36