Thread: Display a certain num of decimals

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    Display a certain num of decimals

    hey..i'm having a brain fart. to display like, a number and then up to 2 decimal places in C, (if it was a double) you would do it with printf("%.2lf"); but how would you accomplish the same thing with C++? because you can't really specify such a thing with cout << amount;

    thanks
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    ahh...i just looked up the iomanip header and found setprecision() :]
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a searching tree
    By lindaonline15 in forum C++ Programming
    Replies: 2
    Last Post: 10-15-2008, 06:06 AM
  2. help! fifo read problem
    By judoman in forum C Programming
    Replies: 1
    Last Post: 08-16-2004, 09:19 AM
  3. Problem Using bsearch
    By Zildjian in forum C Programming
    Replies: 4
    Last Post: 11-13-2003, 08:14 PM
  4. Optimization of code
    By dpro in forum C++ Programming
    Replies: 5
    Last Post: 10-28-2002, 04:01 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM