fork download
  1. #include <stdio.h>
  2.  
  3. void main(){
  4. double a, b;
  5. a = 0.1;
  6. b = 0.2;
  7.  
  8. printf("a+b %s 0.3\n", ((a+b == 0.3) ? "==" : "!="));
  9. printf("(a+b)*10 %s 3\n", (((a+b)*10 == 3) ? "==" : "!="));
  10. printf("(int)((a+b)*10) %s 3\n", (((int)((a+b)*10) == 3) ? "==" : "!="));
  11. }
  12.  
Runtime error #stdin #stdout 0s 2112KB
stdin
Standard input is empty
stdout
a+b != 0.3
(a+b)*10 != 3
(int)((a+b)*10) == 3