M_PI

This is a discussion on M_PI within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, Does anyone know if they have dropped the constant "M_PI" in the <cmath> or <math.h> header? Until now, ...

  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
    21,594
    I do not think that it was ever part of standard C++ (or standard C).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21