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

Discussion in 'C++' started by AciD_X, Apr 1, 2004.

  1. AciD_X

    AciD_X Guest

    On Wed, 31 Mar 2004 10:39:52 -0700, Jonathan Turkanis wrote:

    >
    > "osmium" <> wrote in message
    > news:c4ev62$2hoojv$-berlin.de...
    >> 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 ?
     
    AciD_X, Apr 1, 2004
    #1
    1. Advertising

  2. "AciD_X" <> wrote in message
    news:p...
    > On Wed, 31 Mar 2004 10:39:52 -0700, Jonathan Turkanis wrote:
    >
    > >
    > > "osmium" <> wrote in message
    > > news:c4ev62$2hoojv$-berlin.de...
    > >> 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
     
    Jonathan Turkanis, Apr 1, 2004
    #2
    1. Advertising

  3. AciD_X

    Bobo Guest

    "Jonathan Turkanis" <> wrote in message news:<c4g2le$2hivok$-berlin.de>...
    > "AciD_X" <> wrote in message
    > news:p...
    > > On Wed, 31 Mar 2004 10:39:52 -0700, Jonathan Turkanis wrote:
    > >
    > > >
    > > > "osmium" <> wrote in message
    > > > news:c4ev62$2hoojv$-berlin.de...
    > > >> 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.
     
    Bobo, Apr 1, 2004
    #3
  4. Bobo wrote in news::

    >> 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/
     
    Rob Williscroft, Apr 1, 2004
    #4
  5. "Bobo" <> wrote in message
    news:...
    > "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
     
    Jonathan Turkanis, Apr 1, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chirs
    Replies:
    18
    Views:
    778
    Chris Uppal
    Mar 2, 2004
  2. Mark Healey
    Replies:
    7
    Views:
    1,497
    Tim Prince
    May 22, 2006
  3. Philipp
    Replies:
    9
    Views:
    1,140
    Mark Space
    Jul 23, 2008
  4. Phrogz
    Replies:
    8
    Views:
    285
    Morton Goldberg
    Feb 8, 2007
  5. VK
    Replies:
    15
    Views:
    1,190
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page