Description
The float type is a floating-point number data type. It has no unsigned equivalent.
A float is guaranteed to be at least 16 bits wide. Its characteristics in a given implementation are specified by macros provided in limits.h, as follows:
This list is incomplete. You can help clc-wiki by expanding it.
FLT_MIN is the minimum positive value that can be represented by a float. It must be positive, and no greater than 1E-37.
FLT_MAX is the greatest positive value that can be represented by a float. It must be at least 1E37.
Floating-point literals are of type double by default, but the suffix F (or f), when added to a floating-point literal, indicates that it should be treated as a float, not a double. So, for example, 6.0 is a double, but 6.0F is a float.
The printf function treats floats as doubles, and the format specifier for a float is therefore the same as for a double: %f. The following program defines a float, assigns a value to it, prints the value, and terminates.
#include <stdio.h> int main(void) { float f = 6.0F; printf("The value of f is %f\n", f); return 0; }
The output of this program is:
The value of f is 6.000000
See also
References
- ISO C99 Standard, 6.2.5