0

In JDK 1.7, Decimalformat(0.00).format(0.045) gives the output 0.05

In JDK 1.8, Decimalformat(0.00).format(0.045) gives the output 0.04

Please let me know why there is a rounding issue to 2 decimal places. Which one is correct?

Vikas Kunte
  • 683
  • 4
  • 15
  • 35
  • 2
    Does this answer your question? [Is inconsistency in rounding between Java 7 and Java 8 a bug?](https://stackoverflow.com/questions/22797964/is-inconsistency-in-rounding-between-java-7-and-java-8-a-bug) – Digsb Nov 24 '21 at 16:37
  • I would think the 1.8 is the more correct. Formatting shouldn't modify the base data. If the user intended for the data to be rounded then they'd perform such operations prior to formatting. – Ryan Nov 24 '21 at 16:39

0 Answers0