M_PIl
Pierre Abbat
phma at phma.optus.nu
Fri Aug 31 10:52:14 PDT 2012
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.
More information about the Users
mailing list