// Andrew Taylor - andrewt@unsw.edu.au // 18/2/2019 // The value 0.1 can not be precisely represented as a double // As a result b != 0 #include int main(void) { double a, b; a = 0.1; b = 1 - (a + a + a + a + a + a + a + a + a + a); if (b == 0) { // better would be fabs(b) < 0.000001 printf("b == 0\n"); } if (b != 0) { printf("1 - (0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1) != 0\n"); } printf("a = %.20lg b = %lg\n", a, b); return 0; }