I'm attempting to store the value 0.9999 into an mpfr_t variable using the mpfr_set_str() function
But 0.9999 is rounded to 1 (or some other value != 0.9999) during storage, no matter the round value (GMP_RNDD, GMP_RNDU, GMP_RNDN, GMP_RNDZ)
So what's the best method to store 0.9999 in an mpfr_t variable using mpfr_set_str()? Is it possible?
Here is my test program, it prints "buffer is: 1", instead of the wanted "buffer is: 0.9999":
int main()
{
size_t precision = 4;
mpfr_t mpfrValue;
mpfr_init2(mpfrValue, precision);
mpfr_set_str(mpfrValue, "0.9999", 10, GMP_RNDN);
char *buffer = (char*)malloc((sizeof(char) * precision) + 3);
mp_exp_t exponent;
mpfr_get_str(buffer,
&exponent,
10,
precision,
mpfrValue,
GMP_RNDN);
printf("buffer is: %s\n", buffer);
free(buffer);
mpfr_clear(mpfrValue);
return 0;
}
Thanks for the help