Если я печатаю NaN с помощью std :: cout или преобразую его в строку, говорит ли стандарт, что он должен быть "nan" как строка?
Существуют ли другие методы для преобразования NaN в строку, где это не так?
#include <iostream>
#include <limits>
int main() {
float x = std::numeric_limits<float>::quiet_NaN();
std::cout << x << '\n'; // Output: nan
std::cout << std::to_string(x) << '\n'; // Output: nan
printf("%f", x); // Output: nan
// possibly other variants to print x
}