Home Java Java-bigdecimal Java bigdecimal valueOf long example



Java bigdecimal valueOf long example
Posted on: November 24, 2008 at 12:00 AM
Example below demonstrates working of bigdecimal class valueOf method. Method returns bigdecimal values.

Java bigdecimal valueOf long example

     

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.

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

Java_bigdecimal_valueOf_long.java

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

public class Java_bigdecimal_valueOf_long  {
  public static void main(String args[]) {

  BigDecimal obj = new BigDecimal(0);

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

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

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

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

Download the code

Related Tags for Java bigdecimal valueOf long example:
cclassstaticobjectconvertmethoddecimalgdvaluereturnexamplelongworkbigdecimalvaluestoexamcibiedemoiminasstamtrjclesworkingembigmeobjrateratesxaxampsurnatkmplstatstrrtrtsvassthbelostatialujeigdpleplono


More Tutorials from this section

Ask Questions?    Discuss: Java bigdecimal valueOf long example  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.