Thread: M_PI

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248

    M_PI

    Hi everyone,

    Does anyone know if they have dropped the constant "M_PI" in the <cmath> or <math.h> header? Until now, I've always used it.. :-(

    Thanks for your answer!

    Mark

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I do not think that it was ever part of standard C++ (or standard C).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    It's not standard, although most implementations provide it. I'd just define it myself:

    Code:
    #include <cmath>
    
    #ifndef M_PI
    #define M_PI 3.14159265358979323846
    #endif
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed