DragonFly BSD
DragonFly users List (threaded) for 2012-08
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

M_PIl


From: Pierre Abbat <phma@xxxxxxxxxxxxx>
Date: Fri, 31 Aug 2012 13:52:14 -0400

I'm developing a program which represents angles internally as binary 
fractions (0x80000000 means 360°). To convert the angle to radians, I used 
M_PI originally, felt I needed more accuracy, and found that Linux has M_PIl, 
which has a few extra digits so that it is accurate as a ten-byte float (the 
processor's internal representation). DFBSD doesn't have M_PIl, so I wrote a 
preprocessor directive which uses M_PI if M_PIl doesn't exist. I run a test 
which adds sin 45° to sin 225° and such combinations around the circle, 
squares the errors, and adds them up.

  printf("total sine error=%e\n",totsinerror);
  printf("total cosine error=%e\n",totcoserror);
  printf("total cis error=%e\n",totciserror);
  assert(totsinerror+totcoserror+totciserror<1e-29);
  //On Linux, the total error is 6e-39 and the M_PIl makes a big difference.
  //On DragonFly BSD, the total error is 5e-30 and M_PIl is absent.

Pierre
-- 
When a barnacle settles down, its brain disintegrates.
Já não percebe nada, já não percebe nada.




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