Thread: setprecision() Help

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    34

    setprecision() Help

    Hi

    ive included

    #include <iomanip.h>

    and im using setprecision(2) to set the precision for my floats

    The problem is that when i execute the program i now get 1.4E+ee etc when i want say 44.67

    Am i missing something?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Try:

    float f = 44.67;

    cout << setiosflags(ios::fixed) << setprecision(2) << f << endl;

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    34
    Thanks that worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. setprecision()
    By hallo007 in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2006, 09:38 AM
  2. setprecision??
    By rachael033 in forum C++ Programming
    Replies: 5
    Last Post: 03-22-2006, 02:33 AM
  3. setprecision() - can I count on it rounding or not?
    By major_small in forum C++ Programming
    Replies: 2
    Last Post: 11-23-2005, 02:26 PM
  4. setprecision()
    By OnionKnight in forum C++ Programming
    Replies: 2
    Last Post: 03-04-2005, 09:08 PM
  5. Setw() and setprecision?
    By Furious_George in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2003, 08:20 AM