Właśnie zauważyłem, że std::nextafter(0, 1)
w moim systemie wydaje się wytwarzać wartość większą niż 0 i niższą niż std::numeric_limits::min()
.W jaki sposób std :: nextafter() w C++ 11 może generować mniejsze wartości niż std :: numeric_limits :: min?
Jak to jest możliwe? Myślałem min()
zwraca najmniejszą możliwą liczbę większą niż 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;
}
Wyjście:
next: 4.94066e-324
min: 2.22507e-308
next<min: 1
next>0: 1
Mój kompilator MinGW 5.3.0 32bit.
Dobre pytanie i kochajcie swoje imię! – Bathsheba