473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

round and M_PI

In MS Visual C++ 6.0

Where is M_PI defined?
Where is round defined?

Jul 19 '05 #1
5 27529
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
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

70
by: Adam | last post by:
Hi, I am using the following code: printf("%g", sin(M_PI)) and getting 1.22461e-16 instead of zero. Does anyone have any idea why, and what I can do about it? Thanks, Adam
0
by: broodle | last post by:
In reply to post http://www.thescripts.com/forum/thread61751.html program this to access M_PI (at least in Visual Studio 2005 8.0) #define _USE_MATH_DEFINES true #include <math.h> not sure...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.