##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::ios_base::precision

From cppreference.com
< cpp‎ | io‎ | ios base

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

Manages the precision (i.e. how many digits are generated) of certain numeric output conversions.

1) Returns the current precision.

2) Sets the precision to the given one.

### [edit] Parameters

new_precision | - | new precision setting

### [edit] Return value

the precision before the call to the function

### [edit] Example

Run this code

    #include <iostream>
    int main()
    {
        std::cout << "The default precision is " << std::cout.precision() << '\n';
    }

Output:

    The default precision is 6

### [edit] See also

width | manages field width (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/io/ios_base/precision&oldid=66542"