-1

I have a scenario where we need to display two zeros i.e 00 after the precision for double value. But unfortunately Java is not returning the second zero.

I have tried the below way but it is returning only one zero after decimal.

double inputvalue = 12345.00;
double d = ((BigDecimal.valueOf(inputvalue)).setScale(2,RoundingMode.UP)).doubleValue();

Expected output: 12345.00 but it is returning 1234.0.

Brunaldo
  • 324
  • 3
  • 11

1 Answers1

1

Have you considered using a string to display the value. e.g. String.format( "%.2f", d)

namingFailed
  • 289
  • 4
  • 10