devxlogo

Floating Point Types

Floating Point Types

C++ defines three floating points datatypes: float, double and long double. Some existing implementations support only two (and in some cases only one) of these three. On such implementations, double and long double are interchangeable.

Your implementation documents the floating point datatypes it supports and their characteristics in the header file or . According to the IEEE specification, type float occupies 32 bits (4 bytes) of which 24 represent the mantissa, 7 bits contain the exponent and 1 bit holds the sign. Type double occupies 64 bits (8 bytes) 53 of which are for the mantissa, 10 bits are for the exponent and one bit is for the sign. Type long double occupies 80 bits (10 bytes) of which 64 are for the mantissa, 16 bits are for the exponent and one bit is the sign bit.

long double can represent the largest values and provides the highest precision, namely 18 digits after the decimal point. double has a precision of 15 digits and float’s precision is limited to six digits.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist