Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ cout format specifier for correct number of decimal points

#include <iostream>
#include <iomanip>

int main()
{
    double d = 122.345;

    std::cout << std::fixed;
    std::cout << std::setprecision(2);
    std::cout << d;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cout #format #specifier #correct #number #decimal #points
ADD COMMENT
Topic
Name
4+5 =