The problem with the write integer part of mpf_t really big numbers to the file
lswierczewski .
luk.swierczewski at gmail.com
Sun Aug 24 22:35:19 UTC 2014
Hello,
I have a problem with GMP.
I don't know how to save to file a floating-point number (mpf_t). I know
that I can use function:
mpf_out_str()
This method have two important restrictions:
1. Scientific notation (I need to use additional conversion)
2. Saved value have restricted precision (as I remember there is above 2000
characters/digits)
As the first point isn't really a problem for me that second disqualify
this method for various reasons. I'm working on really big numbers (up to
even 10^(100 000 000 000)) and I need save only integer part of total value.
There can be used:
gmp_fprintf(fp, "%.0Ff", result);
but this function doesn't save correctly values above (about) 10^(50 000
000) - in my case saves only zero (0). Even if this is a bug in my version
of GMP this function will not be usefully because it can save only 2^31-1
characters (it sends back int type - 4 bytes of number of saved characters)
This gives me maximal value which can be saved equals 2 147 483 647 digits
- which value is far to low and unaccepted for me.
At the moment I have solved problem by using:
gmp_printf("%.0Ff", result);
and start my "program" by using:
./program > output.txt
But function gmp_printf() also have limit for displayed characters
(probably it is also 2^31-1 characters - It doesn't display more characters
for me and displays only zero (0) for bigger values).
I don't know if this is right group to ask how go around my problem.
If is no any simple method I would like do ask for adding new function to
save really big floating-point numbers (mpf_t). In this scenario I need to
save integer part of floating-point precision number.
--
Best Regards
Lukasz Swierczewski
Tel: (+48) 664 297 198
Email: luk.swierczewski at gmail.com
More information about the gmp-discuss
mailing list