diff options
author | Niklas Fiekas <niklas.fiekas@backscattering.de> | 2020-01-16 14:09:19 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@python.org> | 2020-01-16 14:09:19 (GMT) |
commit | c5b79003f5fe6aa28a2a028680367839ba8677db (patch) | |
tree | ef8be6cb5538ff0bf96478f6feed362a71d95dc2 /Include/pymath.h | |
parent | 4691a2f2a2b8174a6c958ce6976ed5f3354c9504 (diff) | |
download | cpython-c5b79003f5fe6aa28a2a028680367839ba8677db.zip cpython-c5b79003f5fe6aa28a2a028680367839ba8677db.tar.gz cpython-c5b79003f5fe6aa28a2a028680367839ba8677db.tar.bz2 |
bpo-31031: Unify duplicate bits_in_digit and bit_length (GH-2866)
Add _Py_bit_length() to unify duplicate bits_in_digit() and bit_length().
Diffstat (limited to 'Include/pymath.h')
-rw-r--r-- | Include/pymath.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/pymath.h b/Include/pymath.h index f869724..63ca972 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -227,4 +227,12 @@ PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); * behavior. */ #define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type)) +/* Return the smallest integer k such that n < 2**k, or 0 if n == 0. + * Equivalent to floor(log2(x))+1. Also equivalent to: bitwidth_of_type - + * count_leading_zero_bits(x) + */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(unsigned int) _Py_bit_length(unsigned long d); +#endif + #endif /* Py_PYMATH_H */ |