setprecision question

This is a discussion on setprecision question within the C++ Programming forums, part of the General Programming Boards category; I need the following to only print out two decimal points. How do I do that? I can't figure it ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    74

    setprecision question

    I need the following to only print out two decimal points. How do I do that? I can't figure it out. If you need full program code, let me know.

    Code:
    ostream& operator<<(ostream& out, Complex& c)
    {
    	out ; if (c._real !=0) out << c._real; if (c._imaginary >=0) out << " + "; 
    	if (c._imaginary > 0) out << c._imaginary;
    	cout << "i";
        return out;
    }

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    74

    Never mind

    I got it!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 06:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21