0
pLZzz! Modules operation....
Hey! I've problem, which is that: How can I solve this..... 2%-8; I know that modules operation but problem is when the left operand is positive and right operand is negative and left-right reverse then how can I solve problem by manually? *pLZzz*
10 Respostas
+ 9
2 % 8 = 2
because 2 / 8 is 0+2r
2 % -8 = -6
because 2 / -8 is 0-6r
and so on...
+ 8
Different languages might have this differently resolved. In Python:
2 % 8 = 2
2 % -8 = -6
-2 % 8 = 6
-2 % -8 = -2
+ 7
You can not "shorten" this. It is not the division operator - it returns the *remainder* of the division. If you divide the two numbers of the division, surely the remainder will be different. But that will be a totally new operation.
+ 2
I assume that you were expected an answer of 2? When I run this in python I get -6. This is fine because 2 and -6 are the same in mod8.
+ 1
I don't think I was very clear. 2 is equal to -6 in mod8. Try both 2%8 and -6%8 in python and you will see that both output 2. This is because both 2 and -6 are 2 greater than a multiple of 8.
+ 1
r is the remainder which is what modulus function returns
0
2% -8;
2 /-8=-6; which is true for modulo:
if I short this 1/-4=-3; which is true for modulo.
then why the answer is 2. Is here other method for modules...
0
-6 is I get by manually but 2 how can I get this answer by manually
0
here 'r' is what?
0
what means 0+2r and 0-6r. Plzz I'm very suspect, explain.