Java BigInteger floatValue() Method

The floatValue() method of Java BigInteger class is used to convert this BigInteger to a float.This conversion is similar to the narrowing primitive conversion from double to float.

Narrowing Primitive Conversion:

According to The Java Language Specification, it is defined as ifthisBigInteger has too great a magnitude to represent as a float, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate.

Syntax:

Returns:

This method returns this BigInteger converted to a float.

Note:
  • This method is specified by floatValue in class Number.
  • When the return value is finite, this conversion can lose information about the precision of the BigInteger value.

Example

Test it Now

Output:

Result of floatValue operation on 123 is   123.0
Result of floatValue operation on -123 is -123.0

Next TopicJava BigInteger




Latest Courses