Aligning 2d array of numbers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Bazell

    Aligning 2d array of numbers

    I have a large array of numbers, say 10,000 rows by 8 columns. The numbers
    are mostly floating point but some integers. I want to align each column by
    the decimal point or right justify the integers. Is there an easy (read
    obvious) way to do this? My current code reads everything in as a string
    and does a split to put each number in an array. So I have an internal
    represenation of what I want, I just have to output it correctly.

    The other issue is I have different input arrays, different precision
    numbers, and different numbers of columns, so I have to do the formatting on
    the fly.

    An example is:

    2.37 2.99 .22 -1.25 648829 1 1 2.5 2
    3.1 1.22 2.78 10.34 23221 1 2 19.2 3

    and I want thse to come out aligne on the decimal point in each column. For
    a given data file, the floats and integers always occur in the same column.

    Thanks,

    Dave


Working...