Why not '0' for the expression $num1 = (22 % 3 == 22 > 3); ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

7th Jun 2021, 12:56 PM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
3 Answers
+ 1
22%3 //=1 22>3 //true = 1 1== 1 //true = 1
7th Jun 2021, 1:14 PM
Solo
Solo - avatar
+ 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 ==
7th Jun 2021, 1:17 PM
durian
durian - avatar
+ 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.
7th Jun 2021, 1:26 PM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar