[3964] in java-interest

home help back first fref pref prev next nref lref last post

RE: Controlling precision in floats/doubles

daemon@ATHENA.MIT.EDU (John Zehr (Starwave))
Tue Dec 5 21:18:54 1995

From: "John Zehr (Starwave)" <JohnZ@starwave.com>
To: "'Java Interest'" <java-interest@java.sun.com>
Date: Tue, 05 Dec 95 12:21:00 PST


     I just asked this question to someone "in the know" this morning.  You 
have to roll your own formatter.  Format specifiers do not exist within the 
present PrintStream class.  You're best bet is to subclass PrintStream and 
create your own printf type function.
                         -John

P.S. Make sure you post it when you are done.

>Hi all,
>
>This should be easy but I couldn't find it in the docs.
>Is there an easy way to control the number of digits
>of precision for floats and doubles, analogous to C's
>printf("%0.2f") for example?  I need this facility
>for a variety of purposes from System.out.print to
>setting the text of a Label.
>
>Thanks!
>
>--Suresh
     
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post