Mail Archives: djgpp/2002/02/17/04:14:22
On Sun, 17 Feb 2002, Brent Ritchie wrote:
> Just a suggestion, you shouldn't rely on *magic* numbers like 3.1415. In my
> opinion it's not good practice. I use this method.
>
> const float pi = (atan(1)*4);
Fortran legacy, I suppose ;-)
I don't recommend to put such a great faith into the quality of the
`atan' library function: you'd be surprised how much some of them
suck, and will give you inaccurate results. (The DJGPP version is
okay, though.)
Also, using integer "1" (without a period to signal a double) here is
dangerous: it will do evil things if you forget to include <math.h>.
So it is much better to use a provided symbol M_PI, which is exact,
and also saves some run-time computation. M_PI is defined on
<math.h>. The only downside is that M_PI isn't ANSI.
- Raw text -