Why are numbers compared incorrectly?
printf("%i\n",6==1==0); //1, а по идее должно быть 0, так как не равны printf("%i\n",0==0==0); //0, по идее 1 Why are numbers compared incorrectly?
printf("%i\n",6==1==0); //1, а по идее должно быть 0, так как не равны printf("%i\n",0==0==0); //0, по идее 1 6==1==0 performed as
(6==1)==0 Since 6==1 is false, the calculation of this value gives 0, which when compared with 0 gives true, i.e. one.
Take the second example yourself - as (0==0)==0 .
Operands are evaluated in turn:
(6==1)==0 ,
(0==0)==0
Source: https://ru.stackoverflow.com/questions/846074/
All Articles