C++ pow unusual type conversion
问题 When I directly output std::pow(10,2), I get 100 while doing (long)(pow(10,2)) gives 99. Can someone explained this please ? cout<<pow(10,2)<<endl; cout<<(long)(pow(10,2))<<endl; The code is basically this in the main function. The compiler is mingw32-g++.exe -std=c++11 using CodeBlocks Windows 8.1 if that helps 回答1: Floating point numbers are approximations. Occasionally you get a number that can be exactly represented, but don't count on it. 100 should be representable, but in this case it