# 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 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 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 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
```

Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.