Aligning 2d array of numbers

D

Dave Bazell

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top