Java BigInteger doubleValue() method

The doubleValue() method of Java BigInteger class is used to convert this BigInteger to a double.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 magnitude to represent as a double, it will be converted to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate.

Syntax

Returns:

This method returns this BigInteger converted to a double.

Note:
  • This method is specified by doubleValue 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  doubleValue operation on 111 is111.0
Result of  doubleValue operation on 22222222  is 2.2222222E7

Next TopicJava BigInteger




Latest Courses