|
<ios>
ios_base& dec ( ios_base& str );
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 value | effect when set |
dec | read/write integral values using decimal base format. |
hex | read/write integral values using hexadecimal base format. |
oct | read/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
1 2 3 4 5 6 7 8 9 10 11 12
|
// 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:
See also
hex | Use hexadecimal base (manipulator function) |
oct | Use octal base (manipulator function) |
|