+ 1

Why is 1%2 ==0 , false?

Why is 1%2 ==0 ,false, isn't it remainder 0 ?

17th May 2023, 4:10 AM
Y W
Y W - avatar
15 ответов
+ 8
Devision: 0.5 ____ 2 | 1.0 -1.0 .0 1/2 = 0.5 && 1 % 2 = 1
17th May 2023, 4:23 AM
TacoBlayno
TacoBlayno - avatar
+ 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.
17th May 2023, 5:23 AM
Vibhor
Vibhor - avatar
+ 6
No, 1 divided by 2 is 0 remainder 1.
17th May 2023, 4:12 AM
Orin Cook
Orin Cook - avatar
+ 4
Because 1 != 0
17th May 2023, 6:03 AM
A͢J
A͢J - avatar
+ 2
Vibhor, he understood what the modulus operator did, he was saying he thought the remainder should be zero.
17th May 2023, 6:28 PM
TacoBlayno
TacoBlayno - avatar
+ 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
17th May 2023, 7:58 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
+ 2
Mihaly Nyilas Correct explanation
17th May 2023, 8:08 PM
Vibhor
Vibhor - avatar
+ 1
Can you explain that?
17th May 2023, 4:13 AM
Y W
Y W - avatar
+ 1
TacoBlayno who knows! 🤖
17th May 2023, 6:33 PM
Vibhor
Vibhor - avatar
+ 1
He literally asked: "isn't it remainder 0?"
17th May 2023, 7:09 PM
Orin Cook
Orin Cook - avatar
+ 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
17th May 2023, 7:49 PM
Vibhor
Vibhor - avatar
+ 1
Because this operator "%" is use for find reminder
18th May 2023, 3:52 PM
RAJ SONI😈😈
RAJ SONI😈😈 - avatar
+ 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
19th May 2023, 12:50 AM
Bob
0
I thought you misunderstood the division operator to be %and used it for another
17th May 2023, 9:39 PM
Precious Uwem
Precious Uwem - avatar
0
0.02 ?
19th May 2023, 3:31 AM
Nazmi Harahap
Nazmi Harahap - avatar