Double Comparison - Numerical Limitations

I have some problems understanding the following code:

double a = -1000; double b = numeric_limits<double>::min(); if (a < b) { cout << "why?"; } 

And the result:

why?

How can -1000 be lower than numeric_limits<double>::min() ?

+5
source share
1 answer

This is because numeric_limits<double>::min(); is the lowest positive number expressed in double precision with a floating point, and not in the most negative number.

+9
source

Source: https://habr.com/ru/post/1236466/


All Articles