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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Java bigdecimal valueOf long method 
 

Example below demonstrates working of bigdecimal class valueOf method. Method returns bigdecimal values.

 

Java bigdecimal valueOf long method

                         

Example below demonstrates working of bigdecimal class valueOf method. Method returns bigdecimal values.  Method converts the long values in to bigdecimal value. Method returns a static bigdecimal object with the specified int scale. 

Syntax for using the method: static BigDecimal longValue(long ln, int i) 
Suppose we have bigdecimal objects x & y & the long variable z & int i;
        then y = x.valueOf(z, i);
System.out.println(y); 

 

Java_bigdecimal_valueOf_long_method.java

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class Java_bigdecimal_valueOf_long_method {

  public static void main(String args[]) {

    BigDecimal obj = new BigDecimal(0);

    long ln = 1345444456;
    System.out.println("long value : " + ln + 
        "\nmethod generated result :"
        + obj.valueOf(ln, 2));

    int in = 4545;
    System.out.println("\ninteger value " +
        ": " + in
        "\nmethod generated result" +
            " :" + obj.valueOf(in, 5));

    ln = 2120022;
    System.out.println("\nlong value : " + ln
        "\nmethod generated result " +
            ":" + obj.valueOf(ln, 4));

    in = 256;
    System.out.println("\ninteger value : " + in
        "\nmethod generated result " +
            ":" + obj.valueOf(in, 2));
  }
}

Download the code

                         

» View all related tutorials
Related Tags: java c exception forms class orm form object io objects integer method format type double decimal gd value number name

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.