# float Java Keyword

float is a Java primitive type.

A float variable may store a single-precision floating point value.

## Examples

      float ratio = .01;
      float diameter = 6.15;
      float height = 1.35E03;  // 1.35 * 103 or 1350.0
      float height = 1e-2;  // 1.0 * 10-2 or 0.01

## Remarks

The following rules apply to this keyword's use:

- Floating point literals in Java always default to double-precision. To specify a single-precision literal value, follow the number with f or F, as in 0.01f.

- Since floating point data types are approximations of real numbers, you should generally never compare floating point numbers for equality.

- Java floating point numbers can represent infinity and NaN (not a number). The Float wrapper class defines the constants MIN_VALUE, MAX_VALUE, NEGATIVE_INFINITY, POSITIVE_INFINITY and NaN.

Related Topics

double Java Keyword