Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Java BigDecimal floatValue method example

Java bigdecimal class floatValue() method translates bigdecimal value in to float type value. Method throws NumberFormatException if it finds value other than a integer or float.

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 floatValue method example

     

Java bigdecimal class floatValue() method translates bigdecimal value in to float type value. Method throws  NumberFormatException if it finds value other than a integer or float. In the example four bigdecimal objects namely: weisz_0, weisz_1, weisz_2 & weisz_3 respectively have been created. 

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

Syntax for using the method: public float floatValue()
System.out.println(bigdecimal_objectName.floatValue()); 
  or
BigDecimal x = this.object.floatValue();

Java_BigDecimal_float.java

import java.math.BigDecimal; 


public class Java_BigDecimal_float {
  public static void main(String args[]) {
  
  String rachel[] {"http://""www.""newstrackindia"".com"};
  BigDecimal weisz_0 = new BigDecimal(rachel.length + 0.451245124512),
  weisz_1 = new BigDecimal(rachel[0].length() 0.1234213421342134),
  weisz_2 = new BigDecimal(rachel[1].length() 0.7896789678967896),
  weisz_3 = new BigDecimal(rachel[2].length() 0.3658365836583658);  
  
  
  System.out.println("BigDecimal objects values \n'weisz_0 '\nvalue : "
  + weisz_0
  +"\nfloat value : " + weisz_0.floatValue());
  
  System.out.println("\n'weisz_1 '\nvalue : " + weisz_1
 +"\nfloat value : " + weisz_1.floatValue());

  System.out.println("\n'weisz_3'\nvalue : " + weisz_2
  +"\nfloat value : " + weisz_2.floatValue());

  System.out.println("\n'weisz_3 '\nvalue : " + weisz_3
  +"\nfloat value : " + weisz_3.floatValue());
  }
}

Download the code

Advertisements

Share on Google+Share on Google+

Java BigDecimal floatValue method 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 floatValue method example  

Post your Comment


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

Ads

 

Ads