Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a reserved word for PI

Status
Not open for further replies.

bd02eagle

Programmer
Jul 7, 2006
15
US
Is there a reserved word for 3.14 so I can get an approximate value in a formaula Im using instead of just being able to use 3.14. Is there a header file that goes with it?
 
Hey
Check the header file of Math.h. In mine are the following definitions

/* Constants rounded for 21 decimals. */
#define M_E 2.71828182845904523536
#define M_LOG2E 1.44269504088896340736
#define M_LOG10E 0.434294481903251827651
#define M_LN2 0.693147180559945309417
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.785398163397448309616
#define M_1_PI 0.318309886183790671538
#define M_2_PI 0.636619772367581343076
#define M_1_SQRTPI 0.564189583547756286948
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT_2 0.707106781186547524401

#define EDOM 33 /* Math argument */
#define ERANGE 34 /* Result too large */
 
Thanks, another way I was going to do it was just by defining a constant as

#define PI ARCCOS(-1)

since arccos(-1) = PI also.
 
Actually thats not working for me either and even though scrumpy's idea is pretty good, does anybody of how Im supposed to code the ArcCos funtion to get a more approximate answer?
 
You mean a more exact answer? acos() is defined in math.h, but you'd be much better off using M_PI as it will be faster.
 
Yea, I found the M_PI function(what I was really looking for a first) in the help file. I guess thats what scrumppy was implying.Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top