decimal point allignment

This is a discussion on decimal point allignment within the C++ Programming forums, part of the General Programming Boards category; I want to print numbers in the following allignmrnt: 455345 989 456.56 Notice that the decimal point will always be ...

  1. #1
    Max
    Max is offline
    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, 01:14 AM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  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
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

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