How check size of floating-point datatypes in C++?

How much bytes have floating-point datatype n C++? For diffrent platform it may be differ number.

To do it You may use header file: cfloat applies constant variables. It is example showsnumber  of digits of in these datatypes. It use constants.

#include 
#include 
using namespace std;

int main()
{
    cout << "Number of decimal digits that can be rounded into a floating-point:\n" << endl;
cout << "- float: " << FLT_DIG << endl;
cout << "- double: " << DBL_DIG << endl;
cout << "- long double: " << LDBL_DIG << endl;

    cout << "Floating-point number of bits in mantissa(decimal digits):\n" << endl;
cout << "- float: " << FLT_MANT_DIG << endl;
cout << "- double " << DBL_MANT_DIG << endl;
cout << "- long double " << LDBL_MANT_DIG << endl;

    cout << "Minimum and maximum integer value for the exponent of a base-10 :\n" << endl;
cout << "- float from " << FLT_MIN_10_EXP << " to " << FLT_MAX_10_EXP << endl;
cout << "- double from " << DBL_MIN_10_EXP << " to " << DBL_MAX_10_EXP << endl;
cout << "- double long from " << LDBL_MIN_10_EXP << " to " << LDBL_MAX_10_EXP << endl;

  return 0;
}

And it is result of running this programm on Windows 7 64-bit:

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.