Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Math constant PI value in C

Tags:

c

Calculating PI value is one of the complex problem and wikipedia talks about the approximations done for it and says it's difficult to calculate PI accurately.

How does C calculate PI? Does it calculate it every time or is it using a less accurate fixed value?

like image 367
user1298016 Avatar asked Mar 28 '12 16:03

user1298016


People also ask

What does M_PI mean in C?

M_PI. Pi, the ratio of a circle's circumference to its diameter. M_PI_2. Pi divided by two. M_PI_4.

Is pi a constant variable?

Pi is an irrational number. Furthermore, it is a transcendental number. Pi is defined as the ratio of the circumference of any circle to its diameter. As all circles are similar and therefore proportional in dimensions, pi is therefore always the same for all circles and is a constant.


1 Answers

In C Pi is defined in math.h: #define M_PI 3.14159265358979323846

like image 141
grifos Avatar answered Sep 19 '22 03:09

grifos