mpf_get_str() is slow for big numbers?

rob shaw rob at
Sun Nov 30 10:09:52 CET 2003

>rob shaw <rob at> writes:
>> The installation of GMP went smoothly on a mac G4 under OS X, but I've
>> noticed that
>> the output of very large numbers via mpf_out_str() is painfully
>> slow.
>Alas, it still uses a quadratic algorithm.  The next release will have
>that fixed.  One workaround is to scale and convert to an integer,
>since integer output is subquadratic.

...i wrote a routine mpf_out_str16() which is specialized to write
out hex characters to disk directly from the mpf_t variable, without
allocating memory for the string, etc.  to write out 25 million hex digits
mpf_out_str() took over 15 hours, the direct version, 3 seconds.
the code, such that it is, is available on request.


More information about the gmp-discuss mailing list