float (Floating point)

The float type

what is a float? A float is a data type that stores decimal numbers, both positive and negative.

how do we use floats? The method of declaring a float variable is: float name; where "float" refers to the floating point type. floats can store numbers from ±1.5 x 10^-45 with 6 digits of precision to ±3.4 x 10^38 with 9 digits of precision.

Example: float variable = 10.5f; float variable = 10;

Last updated

Was this helpful?