Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Is still math.h the C++ math library ?

Reply
Thread Tools

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

 
 
AciD_X
Guest
Posts: n/a
 
      04-01-2004
On Wed, 31 Mar 2004 10:39:52 -0700, Jonathan Turkanis wrote:

>
> "osmium" <> wrote in message
> news:c4ev62$2hoojv$...
>> Jonathan Turkanis writes:
>>
>> > > Well... it's called <cmath> now (and the symbols are in the std
>> > > namespace)... and the "performance" is a QoI (Quality of
>> > Implementation)
>> > > issue. You'd have to take that up with your compiler vendor.
>> >
>> > <math.h> is still part of the standard, although officially
>> > deprecated.

>>
>> I think he means the spelling of <math.h> is deprecated, *not* the

> contents
>> that go with it. I see no reason to cast doubt on the quality of a

> typical
>> implementation. Math is math.

>
> 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 ?



 
Reply With Quote
 
 
 
 
Jonathan Turkanis
Guest
Posts: n/a
 
      04-01-2004

"AciD_X" <> wrote in message
newsan.2004.04.01.00.40.12.58754@rocketNOSPAMmai l.com...
> On Wed, 31 Mar 2004 10:39:52 -0700, Jonathan Turkanis wrote:
>
> >
> > "osmium" <> wrote in message
> > news:c4ev62$2hoojv$...
> >> Jonathan Turkanis writes:


> >
> > 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.


<snip>

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


That's the only difference.

Jonathan


 
Reply With Quote
 
 
 
 
Bobo
Guest
Posts: n/a
 
      04-01-2004
"Jonathan Turkanis" <> wrote in message news:<c4g2le$2hivok$>...
> "AciD_X" <> wrote in message
> newsan.2004.04.01.00.40.12.58754@rocketNOSPAMmai l.com...
> > On Wed, 31 Mar 2004 10:39:52 -0700, Jonathan Turkanis wrote:
> >
> > >
> > > "osmium" <> wrote in message
> > > news:c4ev62$2hoojv$...
> > >> Jonathan Turkanis writes:

>
> > >
> > > 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.

>
> <snip>
>
> > Do they differ in any way other than the namespace they are in ?

>
> 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.
 
Reply With Quote
 
Rob Williscroft
Guest
Posts: n/a
 
      04-01-2004
Bobo wrote in news: om:

>> 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);
>


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.
--
http://www.victim-prime.dsl.pipex.com/
 
Reply With Quote
 
Jonathan Turkanis
Guest
Posts: n/a
 
      04-01-2004

"Bobo" <> wrote in message
news: om...
> "Jonathan Turkanis" <> wrote in message

news:<c4g2le$2hivok$-

> > > >
> > > > 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.

> >
> > <snip>
> >
> > > Do they differ in any way other than the namespace they are in ?

> >
> > 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);
> ...
>


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
Math.min and Math.max for byte / short Philipp Java 9 07-23-2008 12:37 AM
Adding Math.log2 and Math.logn to the core library. Phrogz Ruby 8 02-08-2007 05:00 AM
math.h trig functions questions (and some forgotten high school math) Mark Healey C Programming 7 05-22-2006 10:42 AM
Why can I not use: Math a=new Math(); chirs Java 18 03-02-2004 06:00 PM



Advertisments