I've looked on google and couldn't find the answer and thought i'd ask PARI/GP users here. My question is simply How do you get bit_length() in PARI/GP, that you can use at there interpreter here: https://pari.math.u-bordeaux.fr/gp.html
Asked
Active
Viewed 123 times
3 Answers
2
For integers, it is just bit_length(n) = #binary(n);
. For example:
bit_length(n) = #binary(n);
bit_length(100)
> 7

Piotr Semenov
- 1,761
- 16
- 24
1
Faster for large numbers than binary
is just to use logint
(requires n > 0
).
1 + logint(n,2)

Andrew
- 873
- 4
- 10