Float and Double are primitive data types in C used to store decimal (floating-point) values. Both can store numbers with fractional parts, but they differ in precision, memory usage, and range.
- float stores single-precision floating-point numbers.
- double stores double-precision floating-point numbers with higher accuracy.
Float
The float data type is used to store decimal numbers with single precision. It is suitable when moderate precision is sufficient and memory consumption needs to be minimized.
- Occupies 4 bytes (32 bits) of memory.
- Provides precision of approximately 6–7 decimal digits.
- Stores values ranging from 3.4 × 10⁻³⁸ to 3.4 × 10³⁸.
- Uses %f format specifier.
Syntax
float var_name;
#include <stdio.h>
int main() {
float num = 123.456789f;
printf("Value = %f", num);
return 0;
}
Output
Value = 123.456787
Explanation: The value loses precision after approximately 6–7 decimal digits because a float has limited storage space.
Note: By default, decimal literals are treated as double in C. To explicitly define a float literal, append f or F.
Double
Double is used to store double precision floating point values. It is the greater version of float which can store real numbers with precision up to 15 decimal places.
- The size of the double is 8 bytes.
- The range of double is 1.7x10-308 to 1.7x10+308.
- It can store values up to 15 decimal points without loss of precision.
- The format specifier for double is %lf
Syntax
double variable_name;
#include <stdio.h>
int main(){
double num = 123.456789123456;
printf("Value = %.15lf", num);
return 0;
}
Output
Value = 123.456789123456005
Explanation: A double can store significantly more decimal digits accurately than a float.
How float and double are stored?
C language follows the IEEE 754 standard for representing floating point values in the memory. Unlike the int type that is directly stored in the memory in binary form, the float values are divided into two parts: exponent and mantissa, and then stored.
According to IEEE 754, the floating point values consist of 3 components:
- Sign Bit: This represents the sign of the number. 0 represents positive while 1 represents negative.
- Biased Exponent: The exponent of the number cannot be directly stored as it can be both negative or positive, so we use a biased exponent where we add some bias to the exponent.
- Normalized Mantissa: Matissa is the number in scientific notation, i.e. precision bits of the number.
C float Memory Representation
The size of the float is 32-bit, out of which:
- The most significant bit (MSB) is used to store the sign of the number.
- The next 8 bits are used to store the exponent.
- The remaining 23 bits are used to store the mantissa.

Example
Let's take 65.125 as a decimal number that we want to store in the memory.
Converting to Binary form, we get: 65 = 1000001 0.125 = 001 So, 65.125 = 1000001.001 = 1.000001001 x 106 Normalized Mantissa = 000001001 Now, according to the standard, we will get the baised exponent by adding the exponent to 127, = 127 + 6 = 133 Baised exponent = 10000101 And the signed bit is 0 (positive) So, the IEEE 754 representation of 65.125 is, 0 10000101 00000100100000000000000
C double Memory Representation
The size of the double is 64-bit, out of which:
- The most significant bit (MSB) is used to store the sign of the number.
- The next 11 bits are used to store the exponent.
- The remaining 52 bits are used to store the mantissa.

Example
Let's take the example of the same number 65.125,
From above, 65.5 = 1.000001001 x 106 Normalized Mantissa = 000001001 Now, according to the standard, bais is 1023. So, = 1023 + 6 = 1029 Baised exponent = 10000000101 And the signed bit is 0 (positive) So, the IEEE 754 representation of 65.125 is, 0 10000000101 0000010010000000000000000000000000000000000000000000
Differences between float and double
Points | Float | Double |
|---|---|---|
| Precision | Float is single precision IEEE 754 floating point which provides precision up to 7 decimal points. | Double is double precision IEEE 754 floating point that provides precision up to 15 decimal points. |
| Memory Usage | Float uses 32 bits or 4 bytes of memory. | Double uses 64 bits or 8 bytes of memory. |
| Range | Float can store values varying from 3.4 x 10-38 to 3.4 x 10+38. | The range of double is 1.7x10-308 to 1.7x10+308. |
| Format Specifier | %f is the format specifier for float. | %lf is the format specifier for double. |
| Memory Representation | Sign = 1 bit Exponent = 8 bits Mantissa = 23 bits | Sign = 1 bit Exponent = 11 bits Mantissa = 52 bits |