我的cpp代码中cmath的底层函数有一些不一致的答案,不仅不确定某些值是否确实给出了正确答案
我尝试调试它,不理解它是如何计算答案的
std::cout<<"Floor of 8.01*1000 is : " <<floor(8.01*1000) <<"\n";
std::cout<<"Floor of 8.02*1000 is : " <<floor(8.02*1000) <<"\n";
std::cout<<"Floor of 8.03*1000 is : " <<floor(8.03*1000) <<"\n"; // incorrect result here only : 8029
std::cout<<"Floor of 8.04*1000 is : " <<floor(8.04*1000) <<"\n"; // incorrect result here only : 8039
std::cout<<"Floor of 8.05*1000 is : " <<floor(8.05*1000) <<"\n";
Floor of 8.01*1000 is : 8010
Floor of 8.02*1000 is : 8020
Floor of 8.03*1000 is : 8029 // incorrect result for these values only
Floor of 8.04*1000 is : 8039 // incorrect result for these values only
Floor of 8.05*1000 is : 8050