Thread: Set Precision Help !

  1. #1
    Registered User
    Join Date
    Feb 2002

    Set Precision Help !

    I need to be two decimals precise therefore I am using this code

    outData << setw(10) << set iosflags(ios::fixed) << setprecision(2) << totalGP;
    How come this isn't working ?

  2. #2
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    What do you mean by not working, what are you getting exactly?
    Post the hole code, it's not cauesd by this statement.
    Maybe totalGP is not float or double!

  3. #3
    Registered User
    Join Date
    Apr 2002
    Try "setiosflags(ios::fixed);" rather than separating 'set' and 'iosflags' with a space.

    May be just a 'typo' in your post, but let's not overlook the obvious.

    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  4. #4
    CS Author and Instructor
    Join Date
    Sep 2002
      cout << fixed << setw(10) << setprecision(2) << totalGP;
    Mr. C: Author and Instructor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 08-19-2007, 08:10 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. The new FAQ
    By Hammer in forum A Brief History of
    Replies: 34
    Last Post: 08-30-2006, 10:05 AM
  4. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  5. set precision?
    By Geo-Fry in forum C++ Programming
    Replies: 1
    Last Post: 03-27-2003, 10:03 PM