sizeinbase_gmp#

Return the number of digits $x would take in the given base.

Synopsis#

Math::GMP->new(10**100)->sizeinbase_gmp(10);   # 101
Math::GMP->new(255)->sizeinbase_gmp(2);        # 8

The count may be off by one on the high side — this is libgmp’s documented behaviour for mpz_sizeinbase, which trades accuracy for speed. Use it for buffer sizing, not for exact digit counts.