Div() function

S

Schizoid Man

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

Schizoid Man

Schizoid said:
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.
 
K

Kai-Uwe Bux

Schizoid said:
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 <iostream> or <cmath> are allowed to import other headers: the
div() function is part of <cstdlib>.


Best

Kai-Uwe Bux
 
C

Colander

Schizoid said:
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 <cstdlib> synopsis
Functions:
abs labs srand
div ldiv rand

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

colander
 
S

Schizoid Man

Kai-Uwe Bux said:
The headers <iostream> or <cmath> are allowed to import other headers: the
div() function is part of <cstdlib>.

Hi Kai,

Does <iostream> automatically import <cstdlib>? Because all I have is
<iostream> and <cmath>.
 
J

Jack Klein

Hi Kai,

Does <iostream> automatically import <cstdlib>? Because all I have is
<iostream> and <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 <iostream> or
<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.
 

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
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top