By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

round and M_PI

P: n/a
In MS Visual C++ 6.0

Where is M_PI defined?
Where is round defined?

Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
JustSomeGuy wrote in news:tM62b.826260$3C2.18698362
@news3.calgary.shaw.ca:
In MS Visual C++ 6.0

Where is M_PI defined?
Where is round defined?


They are not defined in standard C++, If you need to know about
Visual C++ ask in one of the ms newsgroups, or do this:

#include <iostream>
#include <ostream>
#include <iomanip>
#include <cmath>
#include <limits>

double const m_pi = 2 * acos(0.0);

inline double round( double d )
{
return floor( d + 0.5 );
}

int main()
{
using namespace std;

cout << setprecision( numeric_limits< double >::digits10 );

cout << m_pi << endl;

cout << floor( m_pi ) << endl;
cout << floor( -m_pi ) << endl;

cout << ceil( m_pi ) << endl;
cout << ceil( -m_pi ) << endl;

cout << round( m_pi ) << endl;
cout << round( -m_pi ) << endl;
}

HTH
Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 19 '05 #2

P: n/a
PT
> In MS Visual C++ 6.0

Where is M_PI defined?
Sorry, I use g++, not MS Visual C++, but maybe I can still be useful...

At my system, M_PI is not defined as such (it doesn't have any memory
associated with it), it's just a macro declared (#define'd) in math.h.
Where is round defined?


round is also declared in math.h (it has a prototype there), but it's
defined somewhere in the maths library (I don't know exactly, which one do
you have).
Jul 19 '05 #3

P: n/a
"PT" <no@spam.to.me> wrote...
In MS Visual C++ 6.0

Where is M_PI defined?


Sorry, I use g++, not MS Visual C++, but maybe I can still be useful...

At my system, M_PI is not defined as such (it doesn't have any memory
associated with it), it's just a macro declared (#define'd) in math.h.
Where is round defined?


round is also declared in math.h (it has a prototype there), but it's
defined somewhere in the maths library (I don't know exactly, which one do
you have).


Neither of the names in the subject line is standard. Not that
it can't be found on your system, just that it's not necessarily
there.

Victor
Jul 19 '05 #4

P: n/a
Victor Bazarov wrote:

Neither of the names in the subject line is standard.


To expand a bit: round is not standard C++, but it's standard C, having
been added in C99.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 19 '05 #5

P: n/a
Must be that Micro$oft decided that PI wasn't object oriented, and that no
one would need a rounding method.
"Pete Becker" <pe********@acm.org> wrote in message
news:3F***************@acm.org...
Victor Bazarov wrote:

Neither of the names in the subject line is standard.


To expand a bit: round is not standard C++, but it's standard C, having
been added in C99.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.