I have this code:
#include <iostream>
int main() {
double val = -400.0;
const double constVal = -400.0;
std::cout << val << std::endl;
std::cout << static_cast<unsigned>(val) << std::endl;
std::cout << constVal << std::endl;
std::cout << static_cast<unsigned>(constVal) << std::endl;
return 0;
}
When I run it, this is the output:
-400
4294966896
-400
0
Why does this happen? A moderate amount of Googling shows nothing on this matter.