help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] help needed on extended precision


From: Wilson Y. Zou
Subject: [Help-gsl] help needed on extended precision
Date: Tue, 27 Apr 2004 14:40:51 +0200

hello, 

I am trying to figure how I could use extended precision in my program.  I have 
been testing the sample program after I set  export 
GSL_IEEE_MODE="extended-precision".  I am just wondering in order to let this 
"extended precision" work, how do I define the data type for "x", "oldsum" and 
"sum", - long double??  

Also, I am a little bit worrying about the fact that I am using Intel Pentium 
III processor, since I read some article that to achieve the extended precision 
also depends on the machine.  Is that true?

Thank you in advance if anyone who can answer the question. 

best wishes,
WILSON

b.t.w. I am using "gcc" to compile.


#include <stdio.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_ieee_utils.h>

int
main (void)
{
  double x = 1, oldsum = 0, sum = 0; 
  int i = 0;

  gsl_ieee_env_setup (); /* read GSL_IEEE_MODE */

  do 
    {
      i++;
      
      oldsum = sum;
      sum += x;
      x = x / i;
      
      printf ("i=%2d sum=%.18f error=%g\n",
              i, sum, sum - M_E);

      if (i > 30)
         break;
    }  
  while (sum != oldsum);

  return 0;
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]