Div() function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Schizoid Man

    #1

    Div() function

    Is Div() a standard C++ function with iostream or cmath? It seems to be
    an incredibly useful function, and works well in Visual C++.

    But I don't want to use to non-standard syntax for my project.

    Thanks.
  • Schizoid Man

    #2
    Re: Div() function

    Schizoid Man wrote:
    Is Div() a standard C++ function with iostream or cmath? It seems to be
    an incredibly useful function, and works well in Visual C++.
    >
    But I don't want to use to non-standard syntax for my project.
    I also meant to add that numerous Google searches haven't turned up
    anything.

    According to Cplusplus.com, div() is not a member of either <iostream>
    or <cmath>. Yet, these are the only headers I am importing into the
    class that uses this method.

    MSDN has some literature, but I couldn't any references to it anywhere else.

    Thanks.

    Comment

    • Kai-Uwe Bux

      #3
      Re: Div() function

      Schizoid Man wrote:
      Is Div() a standard C++ function with iostream or cmath?
      No.

      It seems to be an incredibly useful function, and works well in Visual
      C++.
      The headers <iostreamor <cmathare allowed to import other headers: the
      div() function is part of <cstdlib>.


      Best

      Kai-Uwe Bux

      Comment

      • Colander

        #4
        Re: Div() function

        Schizoid Man wrote:
        Schizoid Man wrote:
        >
        Is Div() a standard C++ function with iostream or cmath? It seems to be
        an incredibly useful function, and works well in Visual C++.

        But I don't want to use to non-standard syntax for my project.
        >
        I also meant to add that numerous Google searches haven't turned up
        anything.
        >
        According to Cplusplus.com, div() is not a member of either <iostream>
        or <cmath>. Yet, these are the only headers I am importing into the
        class that uses this method.
        >
        MSDN has some literature, but I couldn't any references to it anywhere else.
        It's in <cstdlib>

        Here some (appropriate) text from the standard.....

        26.5 C Library [lib.c.math]

        Table 81-Header <cstdlibsynopsi s
        Functions:
        abs labs srand
        div ldiv rand

        The added signatures are:
        ldiv_t div(long, long); // ldiv()

        colander

        Comment

        • Schizoid Man

          #5
          Re: Div() function

          Kai-Uwe Bux wrote:
          Schizoid Man wrote:
          >
          >Is Div() a standard C++ function with iostream or cmath?
          >
          No.
          >
          >
          >It seems to be an incredibly useful function, and works well in Visual
          >C++.
          >
          The headers <iostreamor <cmathare allowed to import other headers: the
          div() function is part of <cstdlib>.
          Hi Kai,

          Does <iostreamautoma tically import <cstdlib>? Because all I have is
          <iostreamand <cmath>.

          Comment

          • Jack Klein

            #6
            Re: Div() function

            On Tue, 29 Aug 2006 18:17:54 -0700, Schizoid Man <schiz@sf.comwr ote
            in comp.lang.c++:
            Kai-Uwe Bux wrote:
            Schizoid Man wrote:
            Is Div() a standard C++ function with iostream or cmath?
            No.

            It seems to be an incredibly useful function, and works well in Visual
            C++.
            The headers <iostreamor <cmathare allowed to import other headers: the
            div() function is part of <cstdlib>.
            >
            Hi Kai,
            >
            Does <iostreamautoma tically import <cstdlib>? Because all I have is
            <iostreamand <cmath>.
            One of the changes from C to C++ is in the inclusion of standard
            headers.

            The C standard specifically prohibits any standard C header from
            including any other standard C header.

            The C++ standard specifically allows any standard C++ header,
            including those inherited from C, to include any other standard C++
            header.

            So apparently on your particular implementation either <iostreamor
            <cmath>, or both, include <cstdlib>. But your next compiler, or even
            the next version of your current compiler, might not do so. For the
            sake of portability don't count on it, and always implicitly include
            every standard header whose types, objects, macros, or functions you
            use.

            --
            Jack Klein
            Home: http://JK-Technology.Com
            FAQs for
            comp.lang.c http://c-faq.com/
            comp.lang.c++ http://www.parashift.com/c++-faq-lite/
            alt.comp.lang.l earn.c-c++

            Comment

            Working...