aspose file tools*
The moose likes Beginning Java and the fly likes Float / Double format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Float / Double format" Watch "Float / Double format" New topic
Author

Float / Double format

Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
How can I format the output of a float or a double number using the public void println() method


like:

f = 3.151416123f;

System.out.println(f);



I want to see:

% 3.15

Only with two numbers, is this posible?

Does it works like C's fprintf("%2f"); ??? or something?

Any answer would be apreciate


Thanks Zkr Ryz.

Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
This works:

It returns

Hope this helps, Zkr.
Art
Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
It did Art, thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Float / Double format