public class Code { public static void main(String[] args) { double dblFivePointTwo = 5.2; double dblFourPointFive = 4.5; System.out.println("4.6 * 5.2 = " + (dblFourPointSix * dblFivePointTwo)); // It prints "4.6 * 5.2 = 23.919999999999998" // How can I make the answer round off to 23.92? } } Code (markup):
Hi, you should be using the Math.round function which will take the number and the number of digits after the decimal places as argument and produce the output as the number with rounded off values. regards d_s http://www.dsaravanan.wordpress.com/javascript.