Mail Archives: djgpp/1998/03/04/03:29:59
On Tue, 3 Mar 1998, Lawrence Kirby wrote:
> >#include <math.h> /* define M_PI and sin() */
>
> Note however that the C language does not permit a C compiler to define
> M_PI in <math.h>.
ANSI C doesn't define M_PI, but Posix does. It certainly doesn't make
sense to roll your own value for PI if one is already available, since
defining accurate float constants can be tricky.
All modern Unix compilers have this constant, and at least some DOS
ones (e.g., Borland C) do as well. So I think it is safe to use,
perhaps with the following safeguard:
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159 /* use as many digits as you need */
#endif
- Raw text -