Advertisement

fixed point notation?

Started by February 20, 2002 08:20 PM
1 comment, last by Trijhaos 22 years, 9 months ago
I''m working on a program for my c++ class and I was curious if there was a way to make all the numbers show up in fixed point notation without typing setprecision() before each separate occurence. Its a bit disheartening when you have to type that 10 or 20 times. Is there some bit of code that would allow me to tell the program to output ALL the numbers in fixed point notation? Thanks in advance.
If I remember correctly, once you set it, you dot have to UNLESS you want to output a diffrent number of decimals.
So, if you setprecision(2); then every output after that should have 2 until you set it to a diffrent value.
Course, I could be wrong though, I havent used it in a long while.

"cogito, ergo sum" -Descartes
"cogito, ergo sum" -Descartes
Advertisement
Define "show up." If you''re using an output stream, such as cout, you can use this pair of calls:

cout.setf(ios::fixed);
cout.precision(x);

where x is the number of desired decimal places. I believe that''s a standard function, and its results persist past the output; that is, they''re nonvolatile.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

[twitter]warrenm[/twitter]

This topic is closed to new replies.

Advertisement