转载:http://www.csharp-examples.net/string-format-double/ he following examples show how to format float numbers to string in C#. You can use static method String.Format or instance methods double.ToString and float.ToString. Digits after decimal point…
public class StringFormatDemo { public static void main(String[] args) { //String.format 实现了四舍五入 System.out.println(String.format("%.2f",8.1256));//8.13 System.out.println(String.format("%.2f",8.1216));//8.12 System.out.println(String.…