+ 5
C++: comparison precision
Who can explain this output? One less zero, and it's "false" #include <iostream> using namespace std; int main() { float a = 2.0000001; int b = 2; if(a == b){ cout << "true!"; } else { cout << "false"; } return 0; }
3 Answers
+ 2
Is this true independently from the compiler?
+ 1
Also, can you tell me if this code precision can be improved?
https://code.sololearn.com/chgZD5KdzV9m/?ref=app
+ 1
I implemented (well... pasted and copied), setting up also cout.precision():
https://code.sololearn.com/co8uU4xnKKks/?ref=app
Anyway, results are not different by my factorial version....