[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem whith Floating-point functions
From: |
Armando Garcia B. |
Subject: |
Problem whith Floating-point functions |
Date: |
Fri, 20 Apr 2001 16:16:33 -0400 |
Dear Sirs:
I have builded a little program using GNU MP in a Linux RedHat 6.2
system runing in a Pentium II 400 MHz machine (Dell Precision
Worksatation 410).
This simple program just asign a decimal number to a mpf_t variable and
then the variable content is converted to a string. Finally the string
is printed to the standard output.
The program is:
#include <stdio.h>
#include <gmp.h>
main()
{
mpf_t x;
mp_exp_t exp;
mpf_init_set_d( x, 0.001 ); /* x = 0.001 */
mpf_get_str( NULL, &exp, 10, 0, x );
printf( "x(mpf_get_str)=%s(%ld)\n", mpf_get_str( NULL, &exp, 10, 0, x
), exp );
exit( 0 );
}
and I compile the program as follows:
gcc -o testgmp testgmp.c -lgmp
Note that I'm using a 0 in the 4th parameter of the mpf_get_str function
to get all the significative digits.
The result for this program is:
x(mpf_get_str)=100000000000000002082(-2)
^^^^
However, I was expecting "1(-2)" instead of "100000000000000002082(-2)",
ie, only zeros after the number 1.
Coud you please help me in this matter?
My best regards,
Armando Garcia Brown.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Problem whith Floating-point functions,
Armando Garcia B. <=