I think I understand why 0.1 + 0.2 == 0.3
returns 0: Because 0.1 + 0.2
output a double type, which 0.3
isn't...right?
Then why does 1 + 2 == 3.0
return 1 if the expression has different types?
#include <stdio.h>
int main()
{
printf("0.1 + 0.2 == 0.3: %d\n", 0.1 + 0.2 == 0.3); // returns 0 (false).
printf("1 + 2 == 3.0: %d\n", 1 + 2 == 3.0); // returns 1 (true)
return 0;
}