C++ noshowpoint Manipulator

Beginner
5 min read
Updated: Nov 2026
3 examples
iostream

Definition

In C++, noshowpoint turns off showpoint. The stream goes back to its normal way of printing floating-point numbers: a decimal point appears only when it is needed, and trailing zeros are dropped.

That is why 5.0 prints as 5 and 2.50 prints as 2.5. 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::noshowpoint into the stream.

C++
std::cout << std::showpoint << 5.0;      // 5.00000
std::cout << std::noshowpoint << 5.0;    // 5
CallWhat it does
std::cout << std::noshowpointDrops the needless point and zeros.
std::cout << std::noshowpoint << 5.0Prints 5.
std::cout << std::noshowpoint << 2.50Prints 2.5.

If you need a fixed number of digits, use fixed and setprecision. noshowpoint is the opposite idea: show as few digits as possible.

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

Parameters

ParameterDescription
strThe stream. It is passed in for you when you write cout << noshowpoint. 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 noshowpoint.

C++ Examples

Example 1 — Switch showpoint Off

Print the same number in both modes.

C++
#include <iostream>

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

How It Works

  1. showpoint is on, so 5.0 shows the point and five zeros.
  2. noshowpoint turns that off in the middle of the program.
  3. The second 5.0 prints as the short form 5.

Example 2 — Drop the Trailing Zero

A value like 2.50 loses its last zero.

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

int main() {
    std::cout << std::setprecision(3);

    std::cout << std::showpoint << 2.5 << '\n';
    std::cout << std::noshowpoint << 2.5 << '\n';
    return 0;
}

How It Works

  1. setprecision(3) allows three significant digits.
  2. With showpoint, the number is padded to three digits: 2.50.
  3. With noshowpoint, only the needed digits are printed: 2.5.

Example 3 — Print Several Values in the Short Form

Values with different numbers of decimals look clean without padding.

C++
#include <iostream>

int main() {
    double values[] = {1.0, 2.5, 3.25};

    std::cout << std::noshowpoint;
    for (double v : values) {
        std::cout << v << ' ';
    }
    std::cout << '\n';
    return 0;
}

How It Works

  1. The array holds three values with zero, one, and two decimals.
  2. With noshowpoint, each number is printed with only the digits it needs.
  3. The result is 1 2.5 3.25. With showpoint all three would be padded to the same number of digits.

Frequently Asked Questions

It turns off showpoint, so floating-point numbers print without a needless decimal point and trailing zeros.
Yes. A new stream already uses it, so you only need it after showpoint.
Just print it with the default settings, or use noshowpoint if showpoint was turned on before.
No. The precision of the stream still limits the digits, but noshowpoint itself only removes padding.
Use std::fixed with std::setprecision(2).

Next: noshowpos

Stop printing the plus sign for positive numbers.

noshowpos 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.

10 people found this page helpful