Archived

This topic is now archived and is closed to further replies.

Trijhaos

fixed point notation?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.]

Share this post


Link to post
Share on other sites