mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
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().
This commit is contained in:
parent
4691a2f2a2
commit
c5b79003f5
4 changed files with 35 additions and 54 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue