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.7×10-308 to 1.7×10+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 |
C Float and Double
Float and double are two primitive data types in C programming that are used to store decimal values. They both store floating point numbers but they differ in the level of precision to which they can store the values.
In this article, we will study each of them in detail, their memory representation, and the difference between them.