BigInteger floatValue() in Java

floatValue(): This method is available in java.math.BigInteger class of Java.

Syntax:

float java.math.BigInteger.floatValue()

This method converts this BigInteger to float. This conversion is similar to the narrowing primitive conversion from double to float as defined in The Java Language Specification: if this BigInteger has too great a magnitude to represent as a float, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY.

Returns: this BigInteger converted to float.

For Example:

BigInteger bigInteger = new BigInteger("1234")

bigInteger.floatValue() = > It returns 1234.0

Approach

Java

import java.math.BigInteger;

public class BigIntegerfloatValue {
    public static void main(String[] args) {

        BigInteger bigInteger = new BigInteger("1234");
        System.out.println(bigInteger.floatValue());

    }
}

Output:

1234.0

No comments:

Post a Comment