Sorry for posting two messages, but the last mail was not complete. Here is whats missing:<br><br>I have the following problems with the current code:<br><br>1) if precision is set to 9999999 (7 nines) the multiplication needs
0.4 seconds. However if I set the precision to 9999999 (7 nines) the function needs 5,4 seconds.<br>2) if I generate a number which is 100000 digits long, then the problem crashes when it executes mpf_init_set_str(x, createStringDecimal(100000), 0);
<br><br>However with 10000 digits it works fast and fine: mpf_init_set_str(x, createStringDecimal(10000), 0);<br><br>what am I doing wrong ?<br>hope you can help.<br><br>also, how I measure the elapsed time in milliseconds ?
<br><br><br>thank you in advance,<br>Andreas<br><br><br><br><div class="gmail_quote">On Dec 14, 2007 9:47 PM, Andreas Andreakis <<a href="mailto:andreas.andreakis@googlemail.com">andreas.andreakis@googlemail.com</a>> wrote:
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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>
</blockquote></div><br>