function
<ios> <iostream> <iostream>

std::dec

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 decimal base (i.e., radix 10). For input streams, extracted values are also expected to be expressed in 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.

For standard streams, the basefield flag is set to dec on initialization.

Parameters

str
Stream object whose basefield format flag is affected.
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

Argument str.

Example

1
2
3
4
5
6
7
8
9
10
// modify basefield
#include <iostream>     // std::cout, std::dec, std::hex, std::oct

int main () {
  int n = 70;
  std::cout << std::dec << n << '\n';
  std::cout << std::hex << n << '\n';
  std::cout << std::oct << n << '\n';
  return 0;
}


Output:
70
46
106

Data races

Modifies str. Concurrent access to the same stream object may cause data races.

Exception safety

Basic guarantee: if an exception is thrown, str is in a valid state.

See also