c++ incorrect floating point arithmetic
问题 For the following program: #include <iostream> #include <iomanip> using namespace std; int main() { for (float a = 1.0; a < 10; a++) cout << std::setprecision(30) << 1.0/a << endl; return 0; } I recieve the following output: 1 0.5 0.333333333333333314829616256247 0.25 0.200000000000000011102230246252 0.166666666666666657414808128124 0.142857142857142849212692681249 0.125 0.111111111111111104943205418749 Which is definitely not right right for the lower place digits, particularly with respect