Hallo,<br><br>I´m currently evaluating GMP against libraries from other languages (such as from java). I´ve already tried to write a program which multiplies two numbers, but I´m experiencing various problems. Also I´m not very experienced in C++, so I cant tell if its me if I´m using GMP wrong. Thus I need your help, in order to make sure that my function is written correctly and as efficient as possible.
<br><br>This are the conditions:<br>1) precision must be presetup and set to 999999999<br>2) generate a decimal from a string := number (I hava already the method which generates the string / const char)<br>3) calculate number*number
<br>4) show elapsed time in milliseconds for that operation<br><br>Here is my code (using C):<br><br><br>int main() {<br> <br> long precision = 9999999;<br><br> mpf_set_default_prec(precision);<br><br> mpf_t x, result;
<br> <br> mpf_init(result);<br><br> mpf_init_set_str(x, createStringDecimal(10000), 0); <br> //createStringDecimal is already implemented, it returns a floating point number of the given length<br><br> clock_t t1, t2;
<br> t1 = clock();<br> <br> //action<br> mpf_mul(result, x, x);<br> <br> t2 = clock();<br> printf("\nFinished in %.2f seconds.\n\n", (t2-t1)*1.0/CLOCKS_PER_SEC);<br><br> int n = 1000;<br> gmp_printf ("fixed point mpf %.*Ff with %d digits\n", n, x, n);
<br> gmp_printf ("fixed point mpf %.*Ff with %d digits\n", n, result, n);<br> <br> return 0;<br>}<br>