Rounding floaters

Is it possible to round a floating point number to 2 decimal places?If so - how?Younis
[107 byte] By [younis786a] at [2007-10-1 0:37:21]
# 1
f * 100round ff / 100
CeciNEstPasUnProgrammeura at 2007-7-7 16:24:22 > top of Java-index,Security,Event Handling...
# 2
Or format the string that displays the number using DecimalFormat.
levi_ha at 2007-7-7 16:24:22 > top of Java-index,Security,Event Handling...
# 3

// Author:Annie the Looney

import java.text.DecimalFormat;

public class TestDecimal {

public static void main(String[] args) {

DecimalFormat decFormat = new DecimalFormat("#0.##");

float num = 12.34567f;

System.out.println(">>>" +decFormat.format(num));

}

}

An example...

***Annie***

annie79a at 2007-7-7 16:24:22 > top of Java-index,Security,Event Handling...
# 4
Thanks CeciNest - i'll give that a whirl.Yons
younis786a at 2007-7-7 16:24:22 > top of Java-index,Security,Event Handling...
# 5
> Rounding floatersFlush twice.
yawmarka at 2007-7-7 16:24:22 > top of Java-index,Security,Event Handling...
# 6
..and thanks Annie-the-Good-And-Kind-To-Novice-Programmers.That looks good.
younis786a at 2007-7-7 16:24:22 > top of Java-index,Security,Event Handling...