QP School

Full Version: Storing a floating-point number in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Description:

The float data type in C is used to store single-precision floating-point numbers. It typically occupies 4 bytes of memory and can represent a wide range of real numbers. However, it has limited precision, so it may not be suitable for applications requiring high accuracy.

Example:

float pi = 3.14159;

Explanation:

In this example, we declare a variable pi of type float.
We initialize it with the value 3.14159.
The float data type can represent real numbers with a range of approximately ±3.4E+38 and typically has 6 to 9 significant decimal digits of precision.