Computer Science Canada

Difference Between Mod and Rem

Author:  GlobeTrotter [ Wed Mar 30, 2005 6:22 pm ]
Post subject:  Difference Between Mod and Rem

Don't they both give the remainder? For example, using the example that comes w/ turing, changing the mod and rem doesn't effect the program.

Author:  person [ Wed Mar 30, 2005 6:30 pm ]
Post subject: 

try negatives

Author:  jamonathin [ Wed Mar 30, 2005 6:35 pm ]
Post subject: 

This example if from the turing help file (edited a bit), and when the number is positive, they both do the same, but when the number is negative, mod tells you how many you need to get the other number, and rem tell you how much you are over the last time you matched that other number. Buttt, i could be wrong Confused
code:

var eggCount : int
get eggCount
put "You have ", eggCount div 12, " dozen eggs"
put "You have ", eggCount mod 12, " left over - mod"
put "You have ", eggCount rem 12, " left over - rem"

Author:  GlobeTrotter [ Wed Mar 30, 2005 6:38 pm ]
Post subject: 

Thanks

Author:  jamonathin [ Wed Mar 30, 2005 6:39 pm ]
Post subject: 

wow that was a fast respond... Exclamation


: