Java – round to 2 decimal places
•
Java
(Math.round(doubleValue*100))/100.0
(Math.round(doubleValue*100))/100.0
Is there a better way to round the decimal to 2 decimal places?
Solution
DecimalFormat format=new DecimalFormat("#.##");
DecimalFormat format=new DecimalFormat("#.##"); System.out.println(format.format(doubleValue));
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码