ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1457. Heating Main

Digits after the point C++
Posted by MiR 25 Jul 2006 13:53
How to show 6 digits after the point using double/float variable?
Re: Digits after the point C++
Posted by N.M.Hieu ( DHSP ) 25 Jul 2006 15:40
You can do one of the following ways :
1)
fprintf(stdout,"%.6lf ",n) ;
or
printf("%.6lf",n) ;

2)
setprecision( 6 ) ;
cout << n ;
/*
in this way , it won't print out the last zero digits.
for instance :
if n == 0.777 , it will print out "0.777" in stead of "0.777000"
if n == 0.777001 , it will print out exactly 6 digits after the decimal point ( "0.777001" )
*/

Edited by author 25.07.2006 15:55
Re: Digits after the point C++
Posted by MiR 25 Jul 2006 16:08
Thanks!
Re: Digits after the point C++
Posted by KAV 25 Jul 2006 19:29
cout.precision( 6 );
cout << fixed << variable;
Re: Digits after the point C++
Posted by TSU: IVIuxianski 28 Aug 2010 00:38
what if i want zero digits? using c++, not c

Edited by author 28.08.2010 00:39