Mail Archives: djgpp/2001/06/18/13:30:09
Patrick Mitran <pmitran AT tsp DOT ece DOT mcgill DOT ca> wrote:
> Hi,
> when I compile with the -ansi switch, it seems that I don't have a
> predefined constant for PI in math.h.
As the old saying goes: "Well, don't do that, then!". In this case:
don't use -ansi unless you positively have to.
> What would be a good way of getting a numerically accurate value of
> PI that is ANSI compliant?
#include <math.h>
const double pi = 4*atan(1.0);
That's about as portable as it gets, and as numerically accurate as
anything else you'll be doing in the same instance of the program,
using the same C math library implementation.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -