cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : manipulators : dec
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
manipulators
boolalpha
dec
endl
ends
fixed
flush
hex
internal
left
noboolalpha
noshowbase
noshowpoint
noshowpos
noskipws
nounitbuf
nouppercase
oct
resetiosflags
right
scientific
setbase
setfill
setiosflags
setprecision
setw
showbase
showpoint
showpos
skipws
unitbuf
uppercase
ws

-

dec manipulator function
ios_base& dec ( ios_base& str );
<ios>

Use decimal base

Sets the basefield format flag for the str stream to dec.

When basefield is set to dec, integral numerical values inserted into the stream are expressed in the decimal base (radix 10). For input streams, extracted values are also expected to be expressed in the decimal base when this flag is set.

The basefield format flag can take any of the following values (each with its own manipulator):


flag valueeffect when set
decread/write integral values using decimal base format.
hexread/write integral values using hexadecimal base format.
octread/write integral values using octal base format.

The basefield flag is set to dec in standard streams on initialization.

Parameters

str
Stream object where to apply.
Because this function is a manipulator, it is designed to be used alone with no arguments in conjunction with the insertion (<<) and extraction (>>) operations on streams (see example below).

Return Value

A reference to the stream object.

Example

// modify basefield
#include <iostream>
using namespace std;

int main () {
  int n;
  n=70;
  cout << dec << n << endl;
  cout << hex << n << endl;
  cout << oct << n << endl;
  return 0;
}

The execution of this example displays something similar to:

70
46
106

See also

hex Use hexadecimal base (manipulator function)
oct Use octal base (manipulator function)
ios_base::flags Get/set format flags (public member function)
ios_base::setf Set specific format flags (public member function)

Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us