DragonFly users List (threaded) for 2012-08
[
Date Prev][Date Next]
[
Thread Prev][Thread Next]
[
Date Index][
Thread Index]
Re: M_PIl
Personally I just define pi with 4*atan(1). Is there a good reason to use M_PI1 instead?
Cheers,
Jelle
------Original Message------
From: Pierre Abbat
Sender: users-errors@crater.dragonflybsd.org
To: users@crater.dragonflybsd.org
Subject: M_PIl
Sent: Aug 31, 2012 19:52
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]