BigInteger doubleValue() Method in Java Last Updated : 04 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The java.math.BigInteger.doubleValue() converts this BigInteger to a double value. If the value return by this function is too big for a magnitude to represent as a double then it will be converted to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate. There is a chance that this conversion can lose information about the precision of the BigInteger value. Syntax: public double doubleValue() Return Value: The method returns a double value which represents double value for this BigInteger. Examples: Input: BigInteger1=32145 Output: 32145.0 Explanation: BigInteger1.doubleValue()=32145.0. Input: BigInteger1=32145535361361525377 Output: 3.2145535E19 Explanation: BigInteger1.doubleValue()=3.2145535E19. This BigInteger is too big for a magnitude to represent as a double then it will be converted to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate. Below programs illustrate doubleValue() method of BigInteger class: Example 1: Java // Java program to demonstrate doubleValue() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; b1 = new BigInteger("32145"); b2 = new BigInteger("7613721"); // apply doubleValue() method double doubleValueOfb1 = b1.doubleValue(); double doubleValueOfb2 = b2.doubleValue(); // print doubleValue System.out.println("doubleValue of " + b1 + " : " + doubleValueOfb1); System.out.println("doubleValue of " + b2 + " : " + doubleValueOfb2); } } Output: doubleValue of 32145 : 32145.0 doubleValue of 7613721 : 7613721.0 Example 2: When returned double value is too big for a magnitude to represent as a double. Java // Java program to demonstrate doubleValue() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; b1 = new BigInteger("32145535361361525377"); b2 = new BigInteger("7613721535372632367351"); // apply doubleValue() method double doubleValueOfb1 = b1.doubleValue(); double doubleValueOfb2 = b2.doubleValue(); // print doubleValue System.out.println("doubleValue of " + b1 + " : " + doubleValueOfb1); System.out.println("doubleValue of " + b2 + " : " + doubleValueOfb2); } } Output: doubleValue of 32145535361361525377 : 3.2145535361361527E19 doubleValue of 7613721535372632367351 : 7.613721535372632E21 Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#doubleValue() Comment More infoAdvertise with us Next Article BigInteger doubleValue() Method in Java A AmanSingh2210 Follow Improve Article Tags : Java java-basics Java-Functions java-math Java-BigInteger Java-math-package +2 More Practice Tags : JavaJava-BigInteger Similar Reads BigInteger floatValue() Method in Java The java.math.BigInteger.floatValue() converts this BigInteger to a float value. If the value returned by this function is too big for a magnitude to represent as a float then it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. There is a chance that this conve 2 min read BigDecimal doubleValue() Method in Java The java.math.BigDecimal.doubleValue() is an in-built function which converts the BigDecimal object to a double. This function converts the BigDecimal to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate or according to the passed object, if its magnitude is too big to be represent 2 min read BigInteger compareTo() Method in Java The java.math.BigInteger.compareTo(BigInteger value) method Compares this BigInteger with the BigInteger passed as the parameter. Syntax: public int compareTo(BigInteger val)Parameter: This method accepts a single mandatory parameter val which is the BigInteger to compare with BigInteger object. Ret 2 min read BigInteger intValue() Method in Java The java.math.BigInteger.intValue() converts this BigInteger to an integer value. If the value returned by this function is too big to fit into integer value, then it will return only the low-order 32 bits. Further there is chance that this conversion can lose information about the overall magnitude 2 min read AtomicInteger doubleValue() method in Java with examples The java.util.concurrent.atomic.AtomicInteger.doubleValue() is an inbuilt method in java which returns the current value of the AtomicInteger as a Double data-type after performing primitive conversion. Syntax: public double doubleValue() Parameters: The function does not accepts any parameter. Retu 1 min read BigInteger or() method in Java Prerequisite: BigInteger Basics The java.math.BigInteger.or(BigInteger val) method is used to perform bitwise OR of two BigIntegers. One of the BigInteger is passed in parameter and the other on which the function is called. This method returns a negative number if either of the BigIntegers used wit 2 min read BigInteger and() Method in Java The java.math.BigInteger.and(BigInteger val) method returns a BigInteger whose value is bitwise-AND of two BigIntegers. This method returns a negative number if both of the BigIntegers are negative. The and() method applies bitwise-AND operation upon the current bigInteger and bigInteger passed as p 2 min read BigInteger xor() Method in Java Prerequisite: BigInteger Basics The xor(BigInteger val) method returns bitwise-XOR of two bigIntegers. This method returns a negative BigInteger if and only if exactly one of the current bigInteger and the bigInteger passed in parameter id negative. The xor() method of BigInteger class apply bitwise 2 min read BigInteger add() Method in Java with Examples The java.math.BigInteger.add(BigInteger val) is used to calculate the Arithmetic sum of two BigIntegers. This method is used to find arithmetic addition of large numbers of range much greater than the range of biggest data type double of java without compromising with the precision of the result. Th 3 min read BigInteger divide() Method in Java with Examples The java.math.BigInteger.divide(BigInteger val) is used to calculate the division of two BigIntegers. BigInteger class internally uses array of integers for processing, the operation on object of BigIntegers are not as fast as on primitives. This method performs an operation upon the current BigInte 3 min read Like