0

I run the following code:

cout << numeric_limits<long double>::max()  <<"\n" ;
cout << sizeof(long double)<<"\n" ;

The output is:

 1.18973e+4932
 16

How can 16 bytes hold a number so large? I thought the maximum is 2^128 = 3.4 * 10^38 even if it was an integer.

user3288177
  • 479
  • 1
  • 4
  • 9
  • 3
    A floating point number uses part of its data to store an _exponent_. That way, it can store much larger values than standard two's complement integer representations. However, unlike an integer, it won't be able to precisely represent all integer values between its minimum and maximum. – user31601 Jul 17 '18 at 20:59
  • 3
    By only storing the most significant digits. A little bit like how you were able to represent `1.18973e+4932` using fewer than 16 chars. – François Andrieux Jul 17 '18 at 20:59

0 Answers0