+ 1

I need some help please!

I didn't quite get how the "Shorthand Assignment Operators" work, so for an example, can someone solve this for me (its also in the "doing math" page of basic concepts): a=8 a/=3 puts 4%a A detailed explanation would be great but anything can help.

28th Nov 2016, 7:11 PM
Doomba
5 Answers
+ 2
a/=3 should be read like a = a / 3 if you divide a whole number by a whole number you will always receive a whole number (always floored)! So the result of a = a / 3 is 2. 4%a is the remainder of the calculation 4 / a. a is 2 so the remainder of 4 / 2 is 0 since 4 - 2 * 2 = 0 5%2 would be 1 since 5 - 2 * 2 = 1 8%3 would be 2 since 8 - 3 * 2 = 2 3%5 would be 3 since 3 - 5 * 0 = 3 So if the dividend is lower then the divisor the result is the dividend!
28th Nov 2016, 7:16 PM
ordens
ordens - avatar
+ 1
can you please classify the numbers from the example above and solve it one more time? I didnt get how did you get 4/a and 4-2*2 from 4%a
28th Nov 2016, 8:12 PM
Doomba
+ 1
a = 8 a/=3 means a = a / 3 which means a = 8 / 3 Since you divide whole numbers by whole numbers you will always get a floored number back. so a = 8 / 3 = 2 so the actual content of a is now 2! 4%a means you have to look how often a fits into 4 which is 2 times since a = 2! now you look what remains if you substract 4 by the result of how often a fits into 4. since a fits 2 times into 4 and a = 2 you substract 4 by 4 which equals 0 7%2 now you see 2 fits 3 times into 7. 2 * 3 equals 6 7 - 6 equals 1 which is your remainder
28th Nov 2016, 8:45 PM
ordens
ordens - avatar
+ 1
oooooohh. thank you sir. appreciate it a lot.
28th Nov 2016, 8:49 PM
Doomba
+ 1
no problem, you're welcome!
28th Nov 2016, 8:50 PM
ordens
ordens - avatar