I'm trying to understand is this undefined.
#include <iostream>
#include <limits>
int main() {
int integer_number = std::numeric_limits<int>::max();
std::cout << integer_number << std::endl;
float float_number = static_cast<float>(integer_number);
std::cout << float_number << std::endl;
integer_number = static_cast<int>(float_number);
std::cout << integer_number << std::endl;
float_number = std::numeric_limits<float>::max();
std::cout << float_number << std::endl;
return 0;
}
output of a program:
2147483647
2.14748e+09
-2147483648
3.40282e+38
compiling with flags : -std=c++20 -Wall -Wpedantic -Werror -Wconversion -O0