set double format with 2 decimal places [duplicate]
问题 This question already has answers here : Round a double to 2 decimal places [duplicate] (13 answers) Closed 6 years ago . I have a short equation: double compute,computed2; compute=getminutes/60; where getminutes is int and I want to set the equivalent of compute with 2 decimal places. 0.00 how can I format the equivalent with 2 decimal places? Example: compute=45/60 it should be 0.75 Here is my work: DecimalFormat df2 = new DecimalFormat("00.00000"); double computed,computed2 = 00.000;