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
Nov 11, 1998

Suppress Trailing Zeros on Output

The format string "%f" in printf() call displays trailing zeros of its argument:
 
	float num = 1.33;
	printf( "%f", num);  // output: 1.330000
To get rid of the trailing zeros, you should use the "%g" format instead:
 
	float num = 1.33;
	printf( "%g", num); //output: 1.33
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap