测试如下:
System.out.println(String.valueOf(Math.random() * 200000000)); System.out.println(String.valueOf((int)(Math.random() * 2000000000))); System.out.println(Math.random() * 200000000); System.out.println(Math.random() * 20000); System.out.println(1111111.1111111123232); System.out.println(11111111.1111111123232); System.out.println(11111111.1111111123232); System.out.println(11111111.1); System.out.println(11111111);
结果是
6.6195401772027425E7 1616808266 6.5601297295756966E7 10957.692773084893 1111111.1111111124 1.1111111111111112E7 1.1111111111111112E7 1.11111111E7 11111111
说明浮点数,小数点前面超过7位,就是说8位之后就会用科学计数法表示