Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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