0

I my application there's four types of Measurement unit.

  1. kg
  2. Height (cm)
  3. Width (cm)
  4. Length (cm)

So I'm putting this all with a Double as it should, but when I Try to show this on TextView if the value is not a fraction, like 1kg or 1cm, it will show like this : 1.0 cm and 1.0 kg. There's any Library that it could ignore the zero unless if was is necessary, something like : 1.2 or 4.5.

  • also look at [this](http://stackoverflow.com/questions/703396/how-to-nicely-format-floating-numbers-to-string-without-unnecessary-decimal-0) –  Apr 29 '17 at 22:45
  • If accuracy matters, use [`BigDecimal`](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) class rather than `Double` or `double`. – Basil Bourque Apr 29 '17 at 23:53
  • Two JSRs may* be of interest to you: (a) [JSR 275 Measures and Units](http://www.javaworld.com/article/2077770/core-java/introduction-to-jsr-275--measures-and-units.html) and (b) [JSR 363: Units of Measurement API](https://jcp.org/en/jsr/detail?id=363). (*just a guess on my part, I'm not familiar with these JSRs.) – Basil Bourque Apr 29 '17 at 23:58

0 Answers0