In C++, both float and double are the different data types used to save numbers with commas. Let’s explore the differences between float and double.
What is Float?
In the programming world, a float is a data type and 32 bits variable that permits you to store real numbers with fractional components and with commas.
What is Double?
Double is also a data type and 64 bit variable used to store large or real numbers that have fractional values.
Difference between float and double in C/C++
|Single Precision data-type.
|Double precision data type.
|Float data types can store up to 7 digits.
|Double data type can store up to 15 digits
|The format specifier for float is %f.
|The format specifier for double is %lf.
|It is a 32-bit floating-point data type.
|It is a 64-bit floating-point data type.
|It demands 4-bytes of memory space.
|It demands 8-bytes of memory space.
|It has 6-digits of precision.
|It has 15-digits of precision.
|It is affordable and consumes less memory space.
|It is costlier, consumes more memory space.
Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cut off, GATE Previous Year Question Paper, and more.