| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Member functions | ||||
| Formatting | ||||
ios_base::precision | ||||
| Locales | ||||
| Internal extensible array | ||||
| Miscellaneous | ||||
| Member classes | ||||
| Member types | ||||
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 bystd::num_put::do_put.
The default precision, as established bystd::basic_ios::init, is 6.
Contents |
| new_precision | - | new precision setting |
The precision before the call to the function
Output:
The default precision is 6 With default precision d is 12.3457With high precision d is 12.345679
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 189 | C++98 | 'precision' was defined as 'the number of digits after the decimal point', but it is not correct in some cases | corrected |
| manages field width (public member function)[edit] | |
| changes floating-point precision (function)[edit] |