Java BigDecimal doubleValue example

Java bigdecimal class doubleValue() method translates bigdecimal value in to double type value.


 

Ads

Tutorials   
Java Bigdecimal Java bigdecimal toBigIntegerExact example Java bigdecimal shortValue example Java bigdecimal shortValueExact Java bigdecimal signum example Java bigdecimal stripTrailingZeros example Java bigdecimal subtract Java bigdecimal subtract method example Java bigdecimal toBigInteger example Java bigdecimal toEngineeringString example Java bigdecimal toPlainString example Java bigdecimal toString example Java bigdecimal ulp example Java bigdecimal unscaledValue example Java bigdecimal valueOf double example Java bigdecimal valueOf long example Java bigdecimal valueOf long method Java bigdecimal setScale method example Java bigdecimal setScale example Java bigdecimal scaleByPowerOfTen example Java bigdecimal scale example Java bigdecimal round example Java bigdecimal remainder method example Java bigdecimal remainder example Java bigdecimal precision example Java bigdecimal pow method example Java bigdecimal pow example Java bigdecimal plus method example Java bigdecimal plus example Java bigdecimal negate method example Java bigdecimal negate example Java bigdecimal multiply method example Java bigdecimal multiply example Java BigDecimal movePointRight example Java bigdecimal movePointLeft example Java bigdecimal min example Java bigdecimal max example Java BigDecimal divideAndRemainder example Java BigDecimal divideAndRemainder method example Java BigDecimal divide examples Java BigDecimal divideToIntegral example Java BigDecimal divideToIntegral method example Java BigDecimal doubleValue example Java BigDecimal equals example Java BigDecimal hashCode example Java BigDecimal intValue example Java BigDecimal intValueExact example Java BigDecimal longValue example Java BigDecimal longValueExact example Java BigDecimal abs example
Ads

Java BigDecimal doubleValue example

     

Java bigdecimal class doubleValue() method translates bigdecimal value in to double type value. Method throws NumberFormatException if it finds a String bigdecimal value instead of a integer or double value. In the example four bigdecimal objects namely: algorithm_0, algorithm_1, algorithm_2 & algorithm_3 respectively have been created. Except the first object rest all objects are assigned positive decimal values with  java.lang.Math class fields and methods. 

In the example along with method generated result, original BigDecimal value is also shown 

Syntax for using the method: public double doubleValue()
System.out.println(bigdecimal_objectName.doubleValue()));

Java_BigDecimal_doubleValue.java

import java.math.BigDecimal;


public class Java_BigDecimal_doubleValue {
  public static void main(String args[]) {
  
  BigDecimal algorithm_0 = new BigDecimal(-2.523),
  algorithm_1 = new BigDecimal(Math.E),
  algorithm_2 = new BigDecimal(
  Math.cos(Math.toRadians(60.0))),
  algorithm_3 = new BigDecimal(
  Math.toDegrees(Math.tan(Math.toRadians(60.0))));  
  
  
  BigDecimal operation[] 
  {algorithm_0, algorithm_1, algorithm_2, algorithm_3};
  System.out.println("BigDecimal objects values " +
  "\n'algorithm_0 '\nvalue : " + operation[0]
  +"\ndouble value : " + operation[0].doubleValue());
  
  System.out.println("\n'algorithm_1 '\nvalue : " + operation[1]
  +"\ndouble value : " + operation[1].doubleValue());

  System.out.println("\n'algorithm_2 '\nvalue : " + operation[2]
  +"\ndouble value : " + operation[2].doubleValue());

  System.out.println("\n'algorithm_3 '\nvalue : " + operation[3]
  +"\ndouble value : " + operation[3].doubleValue());
  }
}

Download the code

Advertisements

Ads
Share on Google+Share on Google+

Java BigDecimal doubleValue example

Posted on: November 21, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Java BigDecimal doubleValue example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads