Forums.ATC.no

Teknisk => Generelt teknisk => Emne startet av: ATC på 27. ſeptember 2008, 18:24 pm

Tittel: Programming: How to calculate pi
Skrevet av: ATC27. ſeptember 2008, 18:24 pm
Not every programming environment has a constant for pi defined. How can this value be calculated?
Tittel: [Solved] Programming: How to calculate pi
Skrevet av: ATC27. ſeptember 2008, 18:24 pm
If you have functions for basic trigonometry available, you can use the following formula:

pi = 4 * atan(1.0)

The atan() function returns the arc tangent in radians and the value is mathematically defined to be between -PI/2 and PI/2 (inclusive).

See "man 3 atan" for more info.