Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Java BigDecimal doubleValue example 
 

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

 

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

                         

» View all related tutorials
Related Tags: c class object objects integer method type default double decimal gd value return int if biginteger example work bigdecimal values

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.