-2

how can i round a double variables in java into only two decimals?

2 Answers2

0

yourNewFormatedDouble = new DecimalFormat("#.##").format(yourOldDoubleHere);

Lukas Novicky
  • 878
  • 1
  • 15
  • 41
0
DecimalFormat df = new DecimalFormat("0.00##");
String result = df.format(myDouble);
Mureinik
  • 252,575
  • 45
  • 248
  • 283