Round off a double while maintaining the trailing zero
问题 Here is my function to roundoff a number upto two decimals but when the rounded off number is 1.50 it seems to ignore the trailing zero and just returns 1.5 public static double roundOff(double number) { double accuracy = 20; number = number * accuracy; number = Math.ceil(number); number = number / accuracy; return number; } So if I send 1.499 it returns 1.5 where as I want 1.50 回答1: This is a printing poblem: double d = 1.5; System.out.println(String.format("%.2f", d)); // 1.50 回答2: 1.5 is,