No subject

Paul Zimmermann zimmerma at loria.fr
Thu Jan 4 10:43:48 CET 2007


From: Paul.Zimmermann at loria.fr (Paul Zimmermann)
To: comtech.usa at gmail.com
CC: gmp-discuss at swox.com, mpfr at loria.fr
In-reply-to: <b1f16d9d0701032038w55e984b4s3294052ce9a396a1 at mail.gmail.com>
	(message from Michael on Wed, 3 Jan 2007 20:38:41 -0800)
Subject: Re: [MPFR] Is there a way to extract certain portions of digits from GMP or MPFR numbers?

> Date: Wed, 3 Jan 2007 20:38:41 -0800
> From: Michael <comtech.usa at gmail.com>
> 
> Hi all,
> 
> Suppose my program needs to deal with huge numbers with thousands of
> precision digits. However, the focus is on the last 10s of digits of these
> huge numbers. That's to say, the final results is between 0 and 1,  which is
> obtained form a series of calculations of huge numbers, and then add and
> subtract, so only the last a few digits remain, but the intermediate numbers
> can be as large as gamma(1000).
> 
> Is there a way that I can extract the last N digits from large GMP or MPFR
> numbers? Let's say N=10?
> 
> Thanks a lot,

Yes. For example with MPFR, print your variable to say M digits in a string
STR using the mpfr_get_str function, then {STR+M-10,10} is what you want.

Be careful that some roundoff error will be made in the binary -> decimal
conversion, in addition to the error made in your computations.

Paul Zimmermann


More information about the gmp-discuss mailing list