# Newbie: Need help for benchmarking multiplication between two Floating Points.

Fri Dec 14 21:47:18 CET 2007

```Hallo,

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.

This are the conditions:
1) precision must be presetup and set to 999999999
2) generate a decimal from a string := number (I hava already the method
which generates the string / const char)
3) calculate number*number
4) show elapsed time in milliseconds for that operation

Here is my code (using C):

int main() {

long precision = 9999999;

mpf_set_default_prec(precision);

mpf_t x, result;

mpf_init(result);

mpf_init_set_str(x, createStringDecimal(10000), 0);
//createStringDecimal is already implemented, it returns a floating point
number of the given length

clock_t t1, t2;
t1 = clock();

//action
mpf_mul(result, x, x);

t2 = clock();
printf("\nFinished in %.2f seconds.\n\n", (t2-t1)*1.0/CLOCKS_PER_SEC);

int n = 1000;
gmp_printf ("fixed point mpf %.*Ff with %d digits\n", n, x, n);
gmp_printf ("fixed point mpf %.*Ff with %d digits\n", n, result, n);

return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20071214/27a2fafc/attachment.html
```