Thread: floating and double number

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    75

    floating and double number

    You know how in c programming you can define up to how many decimal points you want by %.2f or %.3f in printf......how can i do that with cout???
    thanks

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    cout.setprecision(n);
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    195
    you also have to #include <iomanip.h> then setprecision(number here)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. floating point number comparison
    By lehe in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2009, 07:11 PM
  2. Recognize if the floating number is valid or not in C
    By feb0590 in forum C Programming
    Replies: 3
    Last Post: 04-16-2009, 04:57 AM
  3. help! calculate arbitrary number of floating points
    By cakestler in forum C Programming
    Replies: 5
    Last Post: 02-26-2009, 02:47 PM
  4. Replies: 4
    Last Post: 07-14-2003, 08:11 AM
  5. Floating points and Double output
    By bman1176 in forum C++ Programming
    Replies: 2
    Last Post: 10-11-2001, 12:24 AM