Thread: PI is #defined in <math.h>, right?

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057

    PI is #defined in <math.h>, right?

    Is PI is #defined in <math.h>? Becuase it isn't with my compiler (Dev-c++ 4.0).

    Although it is with DJGPP.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    No, you are looking for M_PI

    Actually, I can't find anywhere in the standard that defines it, so you might have M_PI, but I wouldn't rely on it. #define your own? pi isn't likely to change in the near future.
    Last edited by cwr; 09-07-2005 at 08:58 PM.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    Quote Originally Posted by cwr
    pi isn't likely to change in the near future.
    lol

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    PI IS EXACTLY THREE!
    Code:
    #define PI 3
    (My attempt at starting a flame war)

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    M_PI (like PI) is actually non-standard. But it is a somewhat common extension to math.h

  6. #6
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Yeah, I know how to get PI - just open a calculator and click on pi. But I thought PI was defined in <math.h>. I guess I'll just declare it myself.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    const double pi = 4. * atan(1.);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking problems in Visual Studio
    By h3ro in forum C++ Programming
    Replies: 5
    Last Post: 03-04-2008, 02:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Variables already defined while linking.
    By xconspirisist in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2005, 05:20 AM
  4. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 07:16 AM
  5. Header files
    By borland_man in forum C++ Programming
    Replies: 14
    Last Post: 02-22-2002, 04:30 AM