Difference Between Float and Double in C++ | Testbook.com

Last Updated on Jul 31, 2023
Download As PDF
IMPORTANT LINKS

Float and double are two distinct data types utilized in C++ for storing numbers that include decimal points. Let's delve deeper into the differences between these two data types.

Defining Float

In the realm of programming, a float is a 32-bit data type that allows the storage of real numbers that contain decimal components.


Defining Double

Double, on the other hand, is a 64-bit data type that is designed to store large or real numbers with decimal values.

Comparing Float and Double in C/C++
S.No. FLOAT DOUBLE
1 Data type with single precision. Data type with double precision.
2 Float data types can store numbers up to 7 digits. Double data type can store numbers up to 15 digits.
3 The format specifier for float is %f. The format specifier for double is %lf.
4 It is a 32-bit floating-point data type. It is a 64-bit floating-point data type.
6 Requires 4-bytes of memory space. Requires 8-bytes of memory space.
7 Offers 6-digits of precision. Offers 15-digits of precision.
8 More affordable and requires less memory space. More expensive and requires more memory space.

Continue your learning journey and stay updated with the latest information 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.

Also Explore,

More Articles for Key Differences

Frequently Asked Questions

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.

Double is also a data type and 64 bit variable used to store large or real numbers that have fractional values.

Key differences include precision, memory space required, and the number of digits they can store. For instance, float is a 32-bit data type that can store up to 7 digits, while double is a 64-bit data type that can store up to 15 digits.

Test Series
401.9k Students
SBI PO Mock Test Series 2025 (Pre + Mains)
367 TOTAL TESTS | 13 Free Tests
  • 13 Full Test (Mains)
  • 70 GA/CA Pack
  • 12 Sectional Test (Mains)
  • 89 Chapter Test
  • 2 2025 Trend Based FTs
  • 28 Full Test (Prelims)
  • 45 Most Saved Qs
  • 15 Sectional Test (Prelims)
  • 24 Memory Based Paper
  • 46 Memory Based Sectional Test
  • 23 IBPS Recent Exam MBTs

Get Started
Report An Error