in reply to Re: Opposite of strtol?
in thread Opposite of strtol?

That's a nice little demo of how to set up a simple perl extension - though there are already a number of modules in existence that will do the conversion.

<plug>
Math::GMPz already uses the very same gmp library function:
perl -MMath::GMPz=":mpz" -wle "print Rmpz_get_str(Math::GMPz->new(54), + 13)"
</plug>

It's also available with Math::GMP, too (though the Math::GMP function we use is undocumented):
perl -MMath::GMP=":constant" -wle "print Math::GMP::get_str_gmp(54, 13 +)"
There are other modules, too, that one could use, but these are the only modules I know of that use the gmp library for the task.

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: Opposite of strtol?
by ambrus (Abbot) on Jun 22, 2009 at 08:21 UTC

    Wow, I didn't know there were interfaces to GMP other than Math::BigInt::GMP, and that one does not have an interface to this.

    There's also Math::BaseCnv to print numbers in an arbitary base though.