Thread: decimal point allignment

  1. #1
    Registered User Max's Avatar
    Join Date
    Jul 2002
    Posts
    110

    decimal point allignment

    I want to print numbers in the following allignmrnt:

    455345
    989
    456.56

    Notice that the decimal point will always be in the same spot no matter how large or small is the number

    currently my program prints: 455345
    989
    456.56

    help please!!!!

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Do you want to output the decimal points for all values? For example:

    1234.45
    3333.00

    If yes, use std::fixed and std::showpoint.

    Otherwise, another solution is an ostringstream. You will have to come up with an algorithm to analyze all situation and add spaces at the end of each string variabl.e

    Kuphryn

  3. #3
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Thumbs up

    Look at previous posts (threads) the answer or something similar has allready been answered.
    Mr. C: Author and Instructor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. hex to binary,hex to decimal
    By groovy in forum C Programming
    Replies: 2
    Last Post: 01-25-2006, 02:14 AM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  3. observing whether a point is in a triangle???
    By hebele in forum C++ Programming
    Replies: 1
    Last Post: 05-19-2003, 03:38 PM
  4. fixed point / floating point
    By confuted in forum Game Programming
    Replies: 4
    Last Post: 08-13-2002, 01:25 PM