[prog] School problem, C++ and cout.precision(2);
Jesika
tx_kewtie at earthlink.net
Sat Nov 23 02:54:18 EST 2002
On Fri, 2002-11-22 at 10:33, Davis, Jennifer wrote:
> For some reason, when I try to get the floats to print out, the average
> comes out with no decimal places and the total score comes out in scientific
> notation. If it helps, I was using the Borland C++ compiler 5.5 (I think)
> on Windows 2000.
>
> Any help in figuring out why this is happening would be greatly
> appreciated...
The previous reply on casting should (I think...) solve your scientific
notation problem. To get your output to show the decimal places, use
setiosflags(ios::fixed). Using (ios::showpoint) would essentially
accomplish this as well... many people use both, but it's redundant if
you're using it in conjunction with setprecision().
One of my instructors has a page set up that gives really good
explanations of the <iomanip> functions. He definitely explains it
better than I do!
http://home.satx.rr.com/rdevore/sac/iomanip.htm
HTH,
Jesika
--
-----BEGIN GEEK CODE BLOCK-----
GIT d-- s-:s+ a- C+++ UBLS++++ P- L++++ !E W N- !o ?K
!w O M- V PS+ PE Y+ PGP++ t++ 5 X R-- tv+ b++ DI++++ D
G e* h- r+++ x+++++
------END GEEK CODE BLOCK------
More information about the Programming
mailing list