Translations of this page?:

precision

Syntax:

    streamsize ostream::precision();
    streamsize ostream::precision(streamsize p);

The precision() function either sets or returns the current number of digits that is displayed for floating-point variables. For example, the following code sets the precision of the cout stream to 5:

     float num = 314.15926535;
     cout.precision( 5 );
     cout << num;

This code displays the following output:

     314.16

Related Topics: fill, width

 
• • • IndexRecent changesRSScc