Subject: formatting of numerical output

From: Ronald Michaels <[email-masked]>
Date: Sun, 08 Mar 1998 16:42:37 +0000

Hi - 

I am writing a class in Java to print out an array to stdio.  Any
pointers on how to control the format of double precision numbers in the
printout will be appreciated.  My purpose is to get the cols to line up
and show only 2 or 3 decimals of precision.

I already have this thing running and it is such a useful little utility
for looking inside numerical code.  Has someone already gotten it
perfected?  If I hear any demand, I will post it to you.  It prints real
or complex (JNL), vector or matrix.  My next little utility project is
to print the array to file.

Thanks Ron
-- 
Ronald Michaels                [email-masked]
714 Burnett Station Rd.        423 573-4049
Seymour, TN 37865

---

From: "Dan E. Kelley" <[email-masked]>
Date: Sun, 8 Mar 1998 14:00:55 -0400 (AST)

Have fun.  Lack of adequate (even 1960-s style) numerical output
formatting was one of the things that made me give up on java ... that
and the changing java specification.

> to print the array to file.

Dan E. Kelley                   internet:   mailto:[email-masked]
Oceanography Department         phone:                 (902)494-1694
Dalhousie University            fax:                   (902)494-2885
Halifax, NS, CANADA, B3H 4J1    http://www.phys.ocean.dal.ca/~kelley

---

From: Walter Bays <[email-masked]>
Date: Sun, 08 Mar 1998 14:59:05 -0800

On Sun, 08 Mar 1998 16:42:37 +0000 [email-masked] (Ronald Michaels) wrote:

>Any
>printout will be appreciated.

In JDK 1.0.2 there was no good way to do this, and you had to write your
own formatting class. The best ones I saw were in the "Core Java" book.

Now the situation has improved; for example,

import java.text.DecimalFormat;
DecimalFormat ratioFormat = new DecimalFormat ("###.00");

     - Walter
     (writing my personal opinions, not Sun's)

---

From: Kirk Abbott <[email-masked]>
Date: Sun, 08 Mar 1998 20:24:22 -0500

Hello,

I agree with Walter. The situation is even better than
that. Have a look at:
1) corejava.Format (as mentioned)
2) hb.Format http://www.efd.lth.se/~d93hb/java/printf/
   which is a *full* printf with a simulated var_args, e.g.

   Format.printf("13.4g %12s \n", 
                 args.add(23456789.123).add("hello world"));
3) lava at http://un.cs.byu.edu/~sharky/software/lava

And in response to one of the earlier posts... 
   being on the bleeding edge is sometimes painful...
   Love the java.

Cheers,
Kirk.