• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Float / Double format

 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works:

It returns

Hope this helps, Zkr.
Art
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did Art, thanks!!!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic