Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Nov 29, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 <float.h> or <cfloat>. 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.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date