Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why a double number less than DBL_MIN can be printed?

I assign 0.4543543234343654632452452525254e-323 to a double variable a and print it, although it is less than DBL_MIN, it can still be assigned and printed.

DBL_MAX: 1.79769e+308
FLT_MAX: 3.40282e+38
DBL_MIN: 2.22507e-308
FLT_MIN: 1.17549e-38
a: 4.94066e-324

Why this happens?

like image 258
pakade Avatar asked May 28 '16 03:05

pakade


People also ask

What is Dbl_min?

DBL_MIN is the smallest positive normal double . DBL_TRUE_MIN is the smallest positive double (since C++17). It will be smaller than DBL_MIN when double supports subnormals. Follow this answer to receive notifications.


1 Answers

Actually DBL_MIN is not the smallest value but the smallest normalized value that is representable.

The difference is the leading digit with is 1 for normalized values, while it's 0 for denormal numbers. Mind that denormal numbers could suffer from sever performance issues on hardware with floating processing unit which is not able to manage them in hardware.

But your value, 0.454354e-323, which corresponds to 4.545354e-324 is smaller than the smallest denormal number representble with a double, indeed it gets rounded to 4.94066e-324 which is the real smallest number which can be stored in a double.

like image 54
Jack Avatar answered Oct 05 '22 22:10

Jack