You cannot really round a number. If you want to display it a screen (paper, etc), you have to use NumberFormat class. Run this code to see what it does:Explore API for other functionality/subclasses of this class.
Joined: Oct 13, 2005
Try "x = 1.0 * 2 / 5;" then. Try "System.out.printf("My number is %.3f", z);"
Look up the java.util.Formatter class, and find the methods Formatter.format, String.format, PrintStream.format and PrintStream.printf, which all take the same sort of arguments.
Joined: May 07, 2007
problem solved! thank's everyone for help and i'm quite sure i will need your help again soon. 'till then be well! [ May 07, 2007: Message edited by: darius vaas ]
Use DecimalFormat. this will limit the number of decimal places your answer it and if you haven't already change float to double. Here is some example code where I did almost what it sounds like what you where trying to do. This code divides two numbers and uses decimal format to control the decimals.