floating and double number

This is a discussion on floating and double number within the C++ Programming forums, part of the General Programming Boards category; You know how in c programming you can define up to how many decimal points you want by %.2f or ...

  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, 08: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, 05: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, 09:11 AM
  5. Floating points and Double output
    By bman1176 in forum C++ Programming
    Replies: 2
    Last Post: 10-11-2001, 01:24 AM

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