Re: Is still math.h the C++ math library ?

A

AciD_X

The contents of <math.h> and <cmath> are not the same: <math.h> is
specified to define functions in the global namespace, <cmath> in the
namespace std.

I wasn't commenting on implementation at all.

Jonathan


Do they differ in any way other than the namespace they are in ?
 
B

Bobo

Jonathan Turkanis said:
That's the only difference.

If my memory is right <cmath> includes also overloads for every
<math.h> function, using float instead of double.
<math.h> <cmath>
double sin(double x) double std::sin(double x);
float std::sin(float x);
....

Regards.
Bobo.
 
R

Rob Williscroft

Bobo wrote in
If my memory is right <cmath> includes also overloads for every
<math.h> function, using float instead of double.
<math.h> <cmath>
double sin(double x) double std::sin(double x);
float std::sin(float x);

Nope in C++ <math.h> is something like this:

#include <cmath>

using std::sin;
/* repeat the above line for every name that
<cmath> declares in namespace std
*/

Rob.
 
J

Jonathan Turkanis

Bobo said:
If my memory is right <cmath> includes also overloads for every
<math.h> function, using float instead of double.
<math.h> <cmath>
double sin(double x) double std::sin(double x);
float std::sin(float x);
...

You're right that the C standard library header <math.h> is not the
same as the C++ standard hread <math.h>, but I was sepcifically
talking about the C++ standard library.

In addition, the C99 header <math.h> includes stuff that the C++
header doesn't.

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top