I was cought by suprise that the following code returns false for gcc 13 and clang 18. Why does this happen? Isn’t the number 8.1 representible in both formats?
#include <iostream>
#include <iomanip>
int main()
{
const long double val = 8.1L;
const double val2 = static_cast<double>(val);
const long double val3 = static_cast<long double>(val2);
std::cout << std::boolalpha << (val == val3) << 'n';
return 0;
}