Convert Bigdecimal to float and float to Bigdecimal value in java
Convert Bigdecimal value to float value and float value to Bigdecimal value in java
In this article, we will learn about how to convert variables from Bigdecimal to float and float to Bigdecimal.
1. Convert Bigdecimal to float value:
code:
BigDecimal bd = new BigDecimal("1234.123486");
//BigDecimal to float value
float getInFloat = bd.floatValue();
//BigDecimal to float value
float getInFloat = bd.floatValue();
2. Convert float value to Bigdecimal value:
code:
float fl = 45.6f;
//float value to Bigdecimal value
BigDecimal getInBigdecimal = BigDecimal.valueOf(fl);
//float value to Bigdecimal value
BigDecimal getInBigdecimal = BigDecimal.valueOf(fl);
No comments