Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

precision()

I have a little problem:
in a method I have

cout.setf(ios::showpoint);
cout.precision(2);
cout<<number<<endl;

coutn<<number2<<endl; // this is the problem

this doesn't output number2 .

but if I take out precision(); it outputs just fine

what am I overlooking?

PLEASE help

Thanks
0
strmtrpr
Asked:
strmtrpr
  • 5
  • 3
  • 2
1 Solution
 
The_BrainCommented:
it is suppose to be.

cout.setprecision(2); //set two dec points
cout.setf(ios::fixed); //ENSURES it.
cout.setf(ios::showpoint);

in that order, other wise it is temporary.  :) I think, but the
above order is correct.  first how many, then permanent, the show the point.
hope that solves your problem.
:)
g_dutoit@hotmail.com


0
 
The_BrainCommented:
sorry, it is cout.precision(2) NOT setprecision. SORRY. typo
0
 
nietodCommented:
The order should not matter.  (At least as far as I know.)

you say "this doesn't output number2 . "  Does that mean it doesn't ouput it all?  or do you mean it doesn't ouput it the way you want it.  If so, what do you get and what do you want?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
The_BrainCommented:
Sorry, true, very true.  It doesn't matter.  but to me it does :)
0
 
strmtrprAuthor Commented:
it outputs a  hex looking number.

I tried in the order that THE_BRAIN suggested and it worked fine

thanks for the help.
0
 
nietodCommented:
That doesn"t make sense
0
 
The_BrainCommented:
it doesn't make sense, does it? :)
0
 
strmtrprAuthor Commented:
I can't explain it either.
0
 
The_BrainCommented:
cool name.
0
 
strmtrprAuthor Commented:
I can't explain it either.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now