formatting output with gmp_printf

Kevin Ryde user42 at zip.com.au
Fri Sep 19 10:10:00 CEST 2003


Info Account <info at PerryResearch.com> writes:
>
> I want to be able to output one digit at a time, with single digit precision.

There's no direct way to do that, you'll need to get the full string
of digits and then print them how you want.

> Is there a way with gmp_printf to specify specific portions of target, and only
> output them with whatever precision specified?

There's no notion of precision for controlling the digits printed from
integers.

> Also, what would be the easiest way to take target, and convert it to an
> arbitrary base (larger than 256)?

Repeated division by the desired base.

If the input might be very big then dividing by a power of the base so
as to divide-and-conquer will be fastest, as per what mpn_get_str
does.


More information about the gmp-discuss mailing list