Aligning 2d array of numbers

Discussion in 'Perl' started by Dave Bazell, Jul 31, 2003.

  1. Dave Bazell

    Dave Bazell Guest

    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
    Dave Bazell, Jul 31, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jukka K. Korpela

    Re: (CSS) Aligning signed numbers in cells

    Jukka K. Korpela, Aug 10, 2003, in forum: HTML
    Replies:
    0
    Views:
    472
    Jukka K. Korpela
    Aug 10, 2003
  2. Subra
    Replies:
    25
    Views:
    1,174
    user923005
    Mar 8, 2007
  3. Andrew Tatum

    Fibonacci Numbers and Lucas Numbers

    Andrew Tatum, May 26, 2007, in forum: C++
    Replies:
    6
    Views:
    546
    Howard
    May 27, 2007
  4. Lance Hoffmeyer
    Replies:
    2
    Views:
    514
    Lance Hoffmeyer
    Jul 26, 2007
  5. GIMME
    Replies:
    5
    Views:
    178
    Thomas 'PointedEars' Lahn
    Jul 26, 2004
Loading...

Share This Page