text: Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win
  
  x
  Solved
  
  # Modulo
  
  Posted on 2011-09-28
  Medium Priority
  463 Views
  Can any one please tell me how
  7 mod 10 = 7
  and
  -2 mod 10 =8
  
  Thanks.
  0
  Question by:mustish1
  [X]
  ###### Welcome to Experts Exchange
  
  Add your voice to the tech community where 5M+ people just like you are talking about what matters.
  
  • Help others & share knowledge
  • Earn cash & points
  • 5
  • 5
  • 2
  • +1
  
  LVL 74
  
  Expert Comment
  
  ID: 36718497
  modulo is the remainder after dividing and is always positive.
  
  a mnemonic to help remember them is to think of it is as a circle of values
  
  ``````7  8   9 0 1 2 3 4 5 6 7 8 9 0  1   2  3  4
  -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
  
  ``````
  
  and the pattern of 0-9 loops forever in both positive and negative direction
  0
  
  Author Comment
  
  ID: 36718515
  if i divide 10 by 7 the reminder is 3 not 7
  if i divide 2 by 10 the reminder is 0 not 8
  0
  
  LVL 27
  
  Expert Comment
  
  ID: 36718518
  For positive integers:    7, 17, 27, 37, ...    all equal 7 mod 10.   They have remainder of 7 when divided by 10.
  
  Another way to look at this is to start with 7,  and add 10 as many times as you like.    Since 10 = 0 mod 10
  
  Once you see this you can also subtract 10 as many times as you like.  This can get you into negative numbers.
  
  So  8 = 8 mod 10.     And   (8 -10) = -2 = 8 mod 10      and      (8 -10 - 10) = -12 = 8 mod 10
  0
  
  LVL 27
  
  Expert Comment
  
  ID: 36718544
  >> if i divide 10 by 7 the reminder is 3 not 7
  
  Wrong.   Divde 7 by 10 to get 0 and remainder 8
  
  You have to understand the positive numbers before you tackle the negative.
  0
  
  LVL 27
  
  Expert Comment
  
  ID: 36718551
  >> if i divide 10 by 7 the reminder is 3 not 7
  
  Wrong.   Divde 7 by 10 to get 0 and remainder 7
  0
  
  Author Comment
  
  ID: 36718568
  7/10 = .7
  0
  
  Author Comment
  
  ID: 36718572
  7/10 = .7 with reminder 0
  0
  
  Author Comment
  
  ID: 36718588
  im sory i think i have a thick head.
  0
  
  LVL 27
  
  Expert Comment
  
  ID: 36718601
  Integer division is not the same as division.
  
  27 divided by 10  ==>  2 with remainder 7.       2 * 10 + 7  =  27
  
  7 divided by 10  ==>  0 with remainder 7.        0 * 10 + 7  =   7
  0
  
  Author Comment
  
  ID: 36718626
  ok now i understand. Can you please tell me one  more time the case of negative number.
  0
  
  LVL 27
  
  Accepted Solution
  
  d-glitch earned 2000 total points
  ID: 36718637
  8 + 2  = 10
  0
  
  LVL 74
  
  Expert Comment
  
  ID: 36718824
  Isn't a split in order?
  0
  
  LVL 37
  
  Expert Comment
  
  ID: 36718937
  modulo is basically the remainder of a division problem
  7/10 is 0 with 7 left over (0*10 + 7 = 7) so 7 mod 10 is 7
  16/10 is 1 with 6 left over (1*10 + 6 = 16) so 16 mod 10 is 6
  -2/10 is 0 with -2 left over, but we don't want negative answers so let's fix it
  
  -2/10 is -1 with 8 left over (-1*10 + 8 = -2) so -2 mod 10 is 8
  
  That's how I explain the reasons.
  
  I don't see the need for a split. http:#a36718497 basically just showed him what he already knew (the answers) not why they are the answers.
  0
  
  ## Featured Post
  
  Question has a verified solution.
  
  If you are experiencing a similar issue, please ask a related question
  
  If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
  Gift cards are not a new concept - it's been around for a very long time.  Undoubtedly, over the past you have received such a card or purchased one for a friend or relative.  Are you aware that you've been feeding the machine?  If not, read on :)
  Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.
  Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templaâ€¦
  ###### Suggested Courses
  Course of the Month10 days, 23 hours left to enroll