mpf_clear vs altered precision

Jim White mathimagics at yahoo.co.uk
Wed Dec 21 05:37:49 CET 2005


> Things are a little trickier if you call
mpf_set_prec_raw(), 
> which doesn't change the allocated memory. Make sure
you read 
> its documentation if you intend to use it.
> 
> Cheers,
> Rob

Thanks Rob

I'm adjusting var->_mp_prec directly, which is what
mpf_set_prec_raw boils down to.

You've hit the nail on the head, I had indeed RTFM but
had managed to forget that is says exactly what you'd
expect:

"Before calling mpf_clear it's a good idea to restore
the original precision!"

The precision setting is the only indicator of the
allocated size so that's perfectly reasonable.  :)

Dynamically reducing precision is particularly useful
when summing a convergent series.

Cheers
Jim


More information about the gmp-discuss mailing list