GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::ios_base::precision(3) C++ Standard Libary std::ios_base::precision(3)

std::ios_base::precision - std::ios_base::precision


streamsize precision() const; (1)
streamsize precision( streamsize new_precision ); (2)


Manages the precision (i.e. how many digits are generated) of floating point output
performed by std::num_put::do_put.


1) Returns the current precision.
2) Sets the precision to the given one. Returns the previous precision.


The default precision, as established by std::basic_ios::init, is 6.


new_precision - new precision setting


the precision before the call to the function

// Run this code


#include <iostream>
int main()
{
const double d = 1.2345678901234;
std::cout << "The default precision is " << std::cout.precision() << "\n\n";
std::cout << "With default precision d is " << d << '\n';
std::cout.precision(12);
std::cout << "With high precision d is " << d << '\n';
}


The default precision is 6


With default precision d is 1.23457
With high precision d is 1.23456789012


width manages field width
(public member function)
setprecision changes floating-point precision
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.