+ 1
Logical operator
#include <iostream> using namespace std; int main() { double a=0.1; double b=0.2; double c=0.3; cout<<(a+b==c); return 0; } Why is the result 0,bros ? I think the output is 1 because all variables are double type.
2 Answers
+ 3
Samsil Arefeen Ok understood.
Le Huu Dai Actually computer returns 0.1 + 0.2 = 0.30000000000004 that's why output is 0.
You can get more explaination here..
https://techtalkbook.com/why-0-1-0-2-does-not-equal-0-3/
+ 1
Many thanks, pro.