BigInteger doubleValue() Method in Java Last Updated : 04 Dec, 2018 Suggest changes Share 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() A AmanSingh2210 Follow 0 Article Tags : Java java-basics Java-Functions java-math Java-BigInteger Java-math-package +2 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like