I would like to know how to convert java.lang.Float to java.Math.BigDecimal. Can this be achieved?
Asked
Active
Viewed 1,910 times
-4
Roshana Pitigala
- 7,945
- 8
- 47
- 71
Divya Pai
- 3
- 4
-
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
- 7,945
- 8
- 47
- 71