BigDecimal doubleValue() Method in Java Last Updated : 04 Dec, 2018 Comments Improve Suggest changes Like Article Like Report 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 represented as a double. Note: The information about the decimal precision of the Double value of the given BigDecimal value can be lost even if the return value is finite. Syntax: public double doubleValue() Parameters: The method does not accept any parameters. Return Value: This method returns the double value of this BigDecimal Object. Examples: Input : 11234 Output : 11234.0 Input : 2679.30000 Output : 2679.3 Below programs illustrates the use of byteValueExact() Function: Program 1: Java // Java program to demonstrate doubleValue() method import java.io.*; import java.math.*; public class GFG { public static void main(String[] args) { // Creating a BigDecimal object BigDecimal big; // Creating a Double object Double dob; big = new BigDecimal("4743"); // Assigning the converted value of bg to d dob = big.doubleValue(); // Printing the corresponding double value System.out.println("Double value of " + big + " is " + dob); } } Output: Double value of 4743 is 4743.0 Program 2: Java // Java program to demonstrate doubleValue() method import java.io.*; import java.math.*; public class GFG { public static void main(String[] args) { // Creating a BigDecimal object BigDecimal big; // Creating a Double object Double dob; big = new BigDecimal("6714592679.34008"); // Assigning the converted value of bg to d dob = big.doubleValue(); // Printing the corresponding double value System.out.println("Double value of " + big + " is " + dob); } } Output: Double value of 6714592679.34008 is 6.71459267934008E9 Reference:https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#doubleValue() Comment More infoAdvertise with us Next Article BigDecimal doubleValue() Method in Java R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Java Java-Functions java-math Java-BigDecimal Java-math-package +2 More Practice Tags : JavaMisc Similar Reads BigDecimal byteValueExact() Method in Java The java.math.BigDecimal.byteValueExact() is an in-built function which converts the BigDecimal to a byte and checks for lost information. Any BigDecimal value greater than 127 or less than -128, will generate an exception as it doesn't fit in byte range. Syntax: public byte byteValueExact() Paramet 2 min read BigInteger doubleValue() Method in Java 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 co 2 min read BigDecimal equals() Method in Java The java.math.BigDecimal.equals() method checks for equality of a BigDecimal value with the object passed. This method considers two BigDecimal objects equal if only if they are equal in value and scale. Syntax: public boolean equals(Object obj) Parameters: This function accepts an Object obj as a m 2 min read BigDecimal intValue() Method in Java The java.math.BigDecimal.intValue() is an in-built function which converts this BigDecimal to an integer value. This function discards any fractional part of this BigDecimal. If the result of the conversion is too big to be represented as an integer value, the function returns only the lower-order 3 2 min read BigDecimal floatValue() Method in Java with Examples The java.math.BigDecimal.floatValue() converts this BigDecimal to a float. If this BigDecimal has too great magnitude to represent as a float, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. Note that even when the return value is finite, this conversion ca 2 min read Like