-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
bpo-31031: Unify duplicate bits_in_digit and bit_length #2866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,3 +79,18 @@ round(double x) | |
| return copysign(y, x); | ||
| } | ||
| #endif /* HAVE_ROUND */ | ||
|
|
||
| static const unsigned int BitLengthTable[32] = { | ||
| 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, | ||
| 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 | ||
| }; | ||
|
|
||
| unsigned int _Py_bit_length(unsigned long d) { | ||
|
||
| unsigned int d_bits = 0; | ||
| while (d >= 32) { | ||
|
||
| d_bits += 6; | ||
| d >>= 6; | ||
| } | ||
| d_bits += BitLengthTable[d]; | ||
| return d_bits; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.