function
<ios> <iostream>

std::showpoint

ios_base& showpoint (ios_base& str);
Show decimal point
Sets the showpoint format flag for the str stream.

When the showpoint format flag is set, the decimal point is always written for floating point values inserted into the stream (even for those whose decimal part is zero). Following the decimal point, as many digits as necessary are written to match the precision set for the stream (if any).

This flag can be unset with the noshowpoint manipulator. When not set, the decimal point is only written for numbers whose decimal part is not zero.

The precision setting can be modified using the precision member function.

For standard streams, the showpoint flag is not set on initialization.

Parameters

str
Stream object whose 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
11
12
// modify showpoint flag
#include <iostream>     // std::cout, std::showpoint, std::noshowpoint

int main () {
  double a = 30;
  double b = 10000.0;
  double pi = 3.1416;
  std::cout.precision (5);
  std::cout <<   std::showpoint << a << '\t' << b << '\t' << pi << '\n';
  std::cout << std::noshowpoint << a << '\t' << b << '\t' << pi << '\n';
  return 0;
}

Possible output:
30.000  10000.  3.1416
30      10000   3.1416


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