Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Jan 2, 2001

Switching Between Fixed and Scientific Notation


By default, iostream objects are set to display floating point values in fixed notation. To change this, you apply the 'scientific' manipulator to an output stream object:
 
#include <iostream>
using namespace std;
int main()
{
 double f = 0.1;
 cout<<f<<endl; // fixed notation by default; display 0.1
 cout<<scientific<<f<<endl;   // display 1.0000e-1
 cout<<fixed<<f<<endl; // fixed point again; display 0.1000
}
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap