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

Function _log10_lb

Lib/_pydecimal.py:5980–5987  ·  view source on GitHub ↗

Compute a lower bound for 100*log10(c) for a positive integer c.

(c, correction = {
        '1': 100, '2': 70, '3': 53, '4': 40, '5': 31,
        '6': 23, '7': 16, '8': 10, '9': 5})

Source from the content-addressed store, hash-verified

5978 return coeff, exp
5979
5980def _log10_lb(c, correction = {
5981 '1': 100, '2': 70, '3': 53, '4': 40, '5': 31,
5982 '6': 23, '7': 16, '8': 10, '9': 5}):
5983 """Compute a lower bound for 100*log10(c) for a positive integer c."""
5984 if c <= 0:
5985 raise ValueError("The argument to _log10_lb should be nonnegative.")
5986 str_c = str(c)
5987 return 100*len(str_c) - correction[str_c[0]]
5988
5989##### Helper Functions ####################################################
5990

Callers 1

_power_exactMethod · 0.85

Calls 2

strFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected