I would like to know how to convert java.lang.Float
to java.Math.BigDecimal
. Can this be achieved?
Asked
Active
Viewed 2,521 times
-3

Roshana Pitigala
- 8,437
- 8
- 49
- 80

Divya Pai
- 13
- 1
- 5
-
If you need BigDecimal accuracy, don't use `float` in the first place, use `double` at least or parse the original number as `String` – Peter Lawrey Apr 20 '17 at 10:15
1 Answers
3
Yes try this,
BigDecimal value = new BigDecimal(Float.toString(123.4f));

Roshana Pitigala
- 8,437
- 8
- 49
- 80