I want to print float values as an integer that is if the value is 70.0 then 70 and but if it is 70.1 then it should not change into int value as 70.1?
Asked
Active
Viewed 28 times
-2
-
It is unclear what data type do you want to receive if the argument is `70.1`. – Commander Tvis Sep 18 '21 at 08:18
1 Answers
0
You can use BigDecimal
for your values and call method stripTrailingZeros() to remove zeros.
You can check it:
new BigDecimal("15.00").stripTrailingZeros();
will return:
15
And for float value:
new BigDecimal("15.1").stripTrailingZeros();
Will return:
15.1

wojdzie
- 51
- 2