Java convert BigInteger to float
Tags: BigInteger BigInteger floatValue float
In this Java core tutorial we learn how to use the java.math.BigInteger.floatValue() method to convert a BigInteger value to a float value.
How to convert BigInteger value to float value
To convert a BigInteger object to a float value we can use the java.math.BigInteger.floatValue() method as the following Java example program.
ConvertBigIntegerToFloatExample.java
import java.math.BigInteger;
public class ConvertBigIntegerToFloatExample {
public static void main(String... args) {
BigInteger value = new BigInteger("123456");
float floatValue = value.floatValue();
System.out.println("BigInteger value: " + value);
System.out.println("float value: " + floatValue);
}
}
BigInteger value: 123456
float value: 123456.0
Happy Coding 😊