+ 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.

23rd Jul 2020, 4:06 AM
Huda Le
Huda Le - avatar
2 Respuestas
+ 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/
23rd Jul 2020, 5:21 AM
A͢J
A͢J - avatar
+ 1
Many thanks, pro.
23rd Jul 2020, 5:42 AM
Huda Le
Huda Le - avatar