Java BigDecimal.floatValue()

Syntax

BigDecimal.floatValue() has the following syntax.

public float floatValue()

Example

In the following code shows how to use BigDecimal.floatValue() method.


/* w w  w. j  av a  2s  .c o  m*/
import java.math.BigDecimal;

public class Main {

  public static void main(String[] args) {

    BigDecimal bg = new BigDecimal("1234.123456");

    Float f = bg.floatValue();

    System.out.println(f);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger