0

Is there any Java library that can help me implement this scenario.

Max number of precision: 3 Max number of decimal scale: 1

e.g. the output should be 33.0, 21.9, 3.4, 100, etc.

The 100 here doesn't have a decimal scale with trailing zero cause it has already exceeded the precision(3).

user6090970
  • 137
  • 1
  • 2
  • 13
  • Not for `double` and `float`, but `BigDecimal` is certainly a library that would do this for you. (Arguably, it's outright impossible for `double` and `float`.) – Louis Wasserman Aug 14 '20 at 21:32
  • I'd just use an integer for internal representation. – Ecto Aug 14 '20 at 21:34
  • [How to round a number to n decimal places in Java](https://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java) – Gilbert Le Blanc Aug 14 '20 at 22:08

0 Answers0