+ 1
Why is 1%2 ==0 , false?
Why is 1%2 ==0 ,false, isn't it remainder 0 ?
15 ответов
+ 8
Devision:
0.5
____
2 | 1.0
-1.0
.0
1/2 = 0.5 && 1 % 2 = 1
+ 8
Y W
% is called Modulus Operator and it gives remainder in this case it's 1.
/ is called Division Operator and it gives quotient as output in this case 0.5.
I think you misunderstood the division operator as % and used it.
+ 6
No, 1 divided by 2 is 0 remainder 1.
+ 4
Because 1 != 0
+ 2
Vibhor, he understood what the modulus operator did, he was saying he thought the remainder should be zero.
+ 2
I wasn't here earlier to explain it, but I see, you already got the right answer....
% is a modulus, it gives you a remainder. if is it not divisible at least once, this means:
{ smaller % bigger }, then the smaller number is completely the remainder
+ 2
Mihaly Nyilas Correct explanation
+ 1
Can you explain that?
+ 1
TacoBlayno who knows! 🤖
+ 1
He literally asked: "isn't it remainder 0?"
+ 1
Here integer division is performed where only the integer is considered as quotient and decimal part is discarded that's why 2 goes 0 = 0 and 1-0 = 1.So remainder is 1
+ 1
Because this operator "%" is use for find reminder
+ 1
Are you perhaps confusing modulo with floor/integer division? That statement would be true in that case. Or maybe just ordering issue? 2%1 =0
0
I thought you misunderstood the division operator to be %and used it for another
0
0.02 ?