Active Entries
- 1: "G-d created Arrakis to train the faithful"
- 2: Laila's speech evaluation
- 3: Your friendly neighborhood school
- 4: That was WILD. They can get away with this?
- 5: Endless Levels
- 6: Four year baby update!
- 7: Now we need to ask the real important questions
- 8: Another lunch disappointment
- 9: 🌸 Sakura, Sakura 🌸
- 10: The Long War (in the corner)
Go Dorchadas!
Date: 2013-Oct-19, Saturday 01:15 (UTC)First, I want to say congrats on making a first foray into computer programming!
Second, as far as the -2 mod 5 = 3 thing. That stems, I believe, from a particular element of math I remember from university. Basically if you are working with a certain range of numbers, say 0, 1, 2, 3, 4, then you can define addition operations using those with a modulo of the size of your range. You always have to get back a value in that range. Thus "4+1=0" because it goes beyond your range and wraps around. i.e. (4+1) mod 5 = 0.
When you're working with those, then -2 is "the same as" or technically speaking "congruent to" 3. You can never get back a negative number from a modulo operation. You *have* to get back one of your numbers in the range 0-4.
("Congruent to": two numbers are congruent to each other if you take their difference and the result is evenly divisible by whatever you're using for mod. 3 - (-2) mod 5 = 5 mod 5 = 0, so they are congruent to each other.)
http://mathworld.wolfram.com/Congruence.html