Search code examples
paripari-gp

How do you get bit_length() in PARI/GP


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


Solution

  • For integers, it is just bit_length(n) = #binary(n);. For example:

    bit_length(n) = #binary(n);
    bit_length(100)
    > 7