Thread: Number of decimals

  1. #1
    sugminpung
    Guest

    Question Number of decimals

    What do I do to set number of decimals in C++?

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    What do you mean?
    "He who makes a beast of himself, gets rid of the pain of being a man." Dr. Johnson

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    155
    like 12.04 or 12.045 etc?

    cout.setf(ios::showpoint);
    cout.setf(ios::fixed);
    cout.precision(2);

    The cout.precision line is what you want the rounding to. 2 means to the nearest hundredth, 3 to the nearest thousandth, etc

  4. #4
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Maybe you mean setprecision(), where setprecision(0) means that there are no decimal points...
    none...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help getting program print out the digit in words
    By cosmiccomputing in forum C Programming
    Replies: 26
    Last Post: 04-24-2008, 08:28 AM
  2. Need help with this compiler error
    By Evangeline in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 09:27 AM
  3. Calculating next prime number
    By anilemon in forum C Programming
    Replies: 8
    Last Post: 04-17-2006, 10:38 AM
  4. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM