Java, rounding a double to two decimal places -
i'm trying round double nearest 2 decimal places however, rounding nearest full number.
for example, 19634.0 instead of 19634.95.
this current code use rounding
double area = math.round(math.pi*radius()*radius()*100)/100; i can't see going wrong.
many help.
well, math.round(math.pi*radius()*radius()*100) long. 100 int.
so math.round(math.pi*radius()*radius()*100) / 100 become long (19634).
change math.round(math.pi*radius()*radius()*100) / 100.0. 100.0 double, , result double (19634.95).
Comments
Post a Comment