Confusion with gmp_printf
Bruce M. Axtens
bruce.axtens at gmail.com
Sun Jan 25 17:05:46 CET 2009
Torbjorn Granlund wrote:
> If I am right, you need to do the logarithm fraction, and compute the
> value of n from the number of bits you asked for when initializing f.
> log(2)/log(10) = 0.3010299957...
Possibly one could use a call like this
buff = mpf_get_str( NULL, &exp, 10, 0, res );
and do some arithmetic with exp and strlen( buff ) to calculate the
number of digits either side of the decimal:
gmp_printf ("%*.*Ff", digits_to_the_left, digits_to_the_right, res );
The troubles is, what do you do when you get a negative value in exp?
More information about the gmp-discuss