<story><title>Mod and remainder are not the same</title><url>https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/</url></story><parent_chain><item><author>dmurray</author><text>In algebra, mod is not an operator. We say 17 mod 4 is 1, but what we write is something like&lt;p&gt;17 = 1 (mod 4)&lt;p&gt;To say that 17 and 1 have the same remainder when divided by 4. If you do all of your operations and comparisons mod 4, it doesn&amp;#x27;t matter if we call the number 1 or -3.&lt;p&gt;In real life, we often need the remainder function, and we usually need it with positive numbers (how many eggs will I have left if I put these into boxes of 12). We sometimes call this the modulo function, which is a slight abuse of notation from the algebraic meaning of modulo. For positive numbers, it works completely intuitively. There are a couple of natural ways to extend this to negative numbers - an extension which would be meaningless or irrelevant in algebra - and computer language authors have (usually) called one rem and one mod.</text></item></parent_chain><comment><author>nmyk</author><text>Strictly speaking, it&amp;#x27;s not the case that&lt;p&gt;17 = 1 (mod 4)&lt;p&gt;but rather&lt;p&gt;17 ≅ 1 (mod 4)&lt;p&gt;i.e. &amp;quot;17 is congruent to 1 mod 4&amp;quot;, not &amp;quot;equal&amp;quot;, though congruency mod n is an equivalence relation.</text></comment>
<story><title>Mod and remainder are not the same</title><url>https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/</url></story><parent_chain><item><author>dmurray</author><text>In algebra, mod is not an operator. We say 17 mod 4 is 1, but what we write is something like&lt;p&gt;17 = 1 (mod 4)&lt;p&gt;To say that 17 and 1 have the same remainder when divided by 4. If you do all of your operations and comparisons mod 4, it doesn&amp;#x27;t matter if we call the number 1 or -3.&lt;p&gt;In real life, we often need the remainder function, and we usually need it with positive numbers (how many eggs will I have left if I put these into boxes of 12). We sometimes call this the modulo function, which is a slight abuse of notation from the algebraic meaning of modulo. For positive numbers, it works completely intuitively. There are a couple of natural ways to extend this to negative numbers - an extension which would be meaningless or irrelevant in algebra - and computer language authors have (usually) called one rem and one mod.</text></item></parent_chain><comment><author>alexlarsson</author><text>I don&amp;#x27;t think that is quite true. Yes, for normal intergers 17 and 4, you can say the above. But mod can also be used as an operation on (and into) the equivalence classes of Z mod 4.</text></comment>