C++ showpoint Manipulator

Beginner
5 min read
Updated: Nov 2026
3 examples
iostream

Definition

In C++, showpoint makes a stream always print the decimal point of a floating-point number and keep its trailing zeros. By default 5.0 prints as 5. With showpoint it prints as 5.00000.

The number of digits comes from the precision of the stream, which is 6 significant digits by default. Change it with setprecision. It comes from <ios>, which <iostream> includes.

This is a manipulator. You do not call it on its own. You send it into a stream with << or >>, and it changes how that stream behaves from then on (or does one small job, like ending a line).

Syntax

Put std::showpoint into the stream before the numbers.

C++
std::cout << 5.0;                          // 5
std::cout << std::showpoint << 5.0;        // 5.00000
CallWhat it does
std::cout << std::showpointKeeps the point and trailing zeros.
std::cout << std::showpoint << 5.0Prints 5.00000 with the default precision.
std::cout << std::showpoint << std::setprecision(3) << 2.5Prints 2.50.

If you want a fixed number of digits after the point, fixed with setprecision is usually the better tool.

Library declarations
C++
ios_base& showpoint(ios_base& str);

Parameters

ParameterDescription
strThe stream. It is passed in for you when you write cout << showpoint. You never write this argument yourself.

Return Value

Return ValueDescription
ios_base&A reference to the same stream, so you can keep chaining << or >> after showpoint.

C++ Examples

Example 1 — Keep the Decimal Point and Zeros

Compare a whole-valued double with and without showpoint.

C++
#include <iostream>

int main() {
    std::cout << 5.0 << '\n';
    std::cout << std::showpoint << 5.0 << '\n';
    return 0;
}

How It Works

  1. By default the stream removes the useless .0, so 5.0 prints as 5.
  2. showpoint asks for the point to be shown and for zeros to be kept.
  3. The default precision is six significant digits, so 5.0 becomes 5.00000: one digit before the point and five after.

Example 2 — showpoint with setprecision

The precision decides how many digits are printed in total.

C++
#include <iomanip>
#include <iostream>

int main() {
    std::cout << std::showpoint << std::setprecision(3);
    std::cout << 2.5 << '\n';
    std::cout << 10.0 << '\n';
    return 0;
}

How It Works

  1. setprecision(3) allows three significant digits for every number.
  2. 2.5 has two digits, so showpoint adds a zero and it prints as 2.50.
  3. 10.0 already has two digits before the point, so only one zero is added: 10.0.

Example 3 — Integers Are Not Affected

Only floating-point numbers get a point.

C++
#include <iostream>

int main() {
    std::cout << std::showpoint;
    std::cout << 10 << '\n';
    std::cout << 100.0 << '\n';
    return 0;
}

How It Works

  1. 10 is an int. Integers have no decimal point, so showpoint does nothing to it.
  2. 100.0 is a double. It must show six significant digits: three before the point and three after.
  3. That gives 100.000. If you want fewer zeros, lower the precision with setprecision.

Frequently Asked Questions

It makes floating-point numbers always print a decimal point and keep trailing zeros, so 5.0 shows as 5.00000 instead of 5.
The precision decides it. By default there are 6 significant digits. Use setprecision to change that.
showpoint counts significant digits in total. fixed counts digits after the decimal point. Use fixed with setprecision for money-like output.
No. Only floating-point types (float, double, long double) are affected.
Use std::noshowpoint or cout.unsetf(std::ios::showpoint).

Next: showpos

Print a plus sign in front of positive numbers.

showpos tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful