Thread: help with iomanip

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    38

    help with iomanip

    Hi,

    I am trying to use setprecision to output at most 5 digits after the decimal point of a floating point number. The problem is that it prints out more than 5 digits if there are zeros. For example, if I have a number

    0.0456784523

    I would like to print out
    0.04567

    But instead it prints out 0.045678
    So it doesnt count the 0 as a digit.
    Can somebody tell me how to do this?
    Thanks
    Mark

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Try
    Code:
      double d=0.0456784523;
      cout << fixed << setprecision(5) << d;
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. iomanip
    By ZerOrDie in forum C++ Programming
    Replies: 7
    Last Post: 09-28-2002, 07:26 AM
Website Security Test