# Java.math.BigDecimal.floatValue() Method

## Description

The java.math.BigDecimal.floatValue() converts this BigDecimal to a float. If this BigDecimal has too great a magnitude represent as a float, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. The conversion can also lose information about the precision of the BigDecimal value when the return value is finite.

## Declaration

Following is the declaration for java.math.BigDecimal.floatValue() method.

```public Float floatValue()
```

## Specified by

floatValue in class Number.

NA

## Return Value

This method returns the float value of the BigDecimal Object.

NA

## Example

The following example shows the usage of math.BigDecimal.floatValue() method.

```package com.tutorialspoint;

import java.math.*;

public class BigDecimalDemo {

public static void main(String[] args) {

// create a BigDecimal object
BigDecimal bg;

// create a Float object
Float f;

bg = new BigDecimal("1234.123486");

// assign the converted value of bg to f
f = bg.floatValue();

String str = "Float value of " + bg + " is " + f;

// print f value
System.out.println( str );
}
}
```

Let us compile and run the above program, this will produce the following result −

```Float value of 1234.123486 is 1234.1235
```

java_math_bigdecimal.htm