I just noticed that on my system std::nextafter(0, 1) seems to produce a value greater than 0 and lower than std::numeric_limits::min().
How is this possible? I thought min() returns the smallest possible number greater than 0.
#include <iostream>
int main(int argc, char *argv[])
{
double next = std::nextafter(0.0, 1.0);
double min = std::numeric_limits<double>::min();
std::cout << "next: " << next << "\nmin: " << min << "\nnext<min: " << (next < min) << "\nnext>0: " << (next > 0.0) << std::endl;
}
Output:
next: 4.94066e-324
min: 2.22507e-308
next<min: 1
next>0: 1
My compiler is MinGW 5.3.0 32bit.
Aucun commentaire:
Enregistrer un commentaire