0
Why not '0' for the expression $num1 = (22 % 3 == 22 > 3); ?
Why not '0' for the expression $num1 = (22 % 3 == 22 > 3); ? https://code.sololearn.com/w68p0QKJIsJs/?ref=app
3 odpowiedzi
+ 1
22%3 //=1
22>3 //true = 1
1== 1 //true = 1
+ 1
as Vasiliy said, 1 == true(1) is true,
but even if u change it to 22%5 (which return 2) ,it is also true cause 2(true) == true ,
simple solution is to cast bool to int,(int)(22>3),or use === instead of ==
+ 1
Basiliy, Lily Mea, Thanks a lot!!! My mistake. I'm now clear.
In fact I thought like this (22%3 == 22) > 3. So I'm confused a lot. Thanks again.