Modulus of negative numbers

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I had a doubt regarding the ‘mod’ operator
So far I thought that modulus referred to the remainder, for example
$8 mod 6 = 2$
The same way,
$6 mod 8 = 6$, since $8cdot 0=0$ and $6$ remains.



When I perform an operation such as
1) $-8 mod 6 = 4$
And
2) $-6mod 8 = 2$



I understood part 2) because
on multiplying $8 cdot (-1) =-8$, the remainder becomes $+2$ (I feel that multiplying by $(-1)$ is correct, because in theory $-8$ is a smaller number than $-6$).



However part 1) does not make any sense to me



Could somebody please give me an explanation regarding the above (part 1)
Also do tell me if my way of thinking is wrong.



Thanks In advance.







share|cite|improve this question


















  • 1




    If it isn't $4$ then what non-negative integer between $0$ and $6$ would it be. It can't be $-8$ because $-8 < 0$. It can't be $-8 + 6 = -2$ because $-2 < 0$. It can't be $-8 + 6 + 6 + 6 = 10$ because $10 > 6$ so what other possible number can you get from $-8$ be adding or subtracting multiples of $6$? What is $-8 + 6 + 6$?
    – fleablood
    Aug 15 at 5:52














up vote
3
down vote

favorite












I had a doubt regarding the ‘mod’ operator
So far I thought that modulus referred to the remainder, for example
$8 mod 6 = 2$
The same way,
$6 mod 8 = 6$, since $8cdot 0=0$ and $6$ remains.



When I perform an operation such as
1) $-8 mod 6 = 4$
And
2) $-6mod 8 = 2$



I understood part 2) because
on multiplying $8 cdot (-1) =-8$, the remainder becomes $+2$ (I feel that multiplying by $(-1)$ is correct, because in theory $-8$ is a smaller number than $-6$).



However part 1) does not make any sense to me



Could somebody please give me an explanation regarding the above (part 1)
Also do tell me if my way of thinking is wrong.



Thanks In advance.







share|cite|improve this question


















  • 1




    If it isn't $4$ then what non-negative integer between $0$ and $6$ would it be. It can't be $-8$ because $-8 < 0$. It can't be $-8 + 6 = -2$ because $-2 < 0$. It can't be $-8 + 6 + 6 + 6 = 10$ because $10 > 6$ so what other possible number can you get from $-8$ be adding or subtracting multiples of $6$? What is $-8 + 6 + 6$?
    – fleablood
    Aug 15 at 5:52












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I had a doubt regarding the ‘mod’ operator
So far I thought that modulus referred to the remainder, for example
$8 mod 6 = 2$
The same way,
$6 mod 8 = 6$, since $8cdot 0=0$ and $6$ remains.



When I perform an operation such as
1) $-8 mod 6 = 4$
And
2) $-6mod 8 = 2$



I understood part 2) because
on multiplying $8 cdot (-1) =-8$, the remainder becomes $+2$ (I feel that multiplying by $(-1)$ is correct, because in theory $-8$ is a smaller number than $-6$).



However part 1) does not make any sense to me



Could somebody please give me an explanation regarding the above (part 1)
Also do tell me if my way of thinking is wrong.



Thanks In advance.







share|cite|improve this question














I had a doubt regarding the ‘mod’ operator
So far I thought that modulus referred to the remainder, for example
$8 mod 6 = 2$
The same way,
$6 mod 8 = 6$, since $8cdot 0=0$ and $6$ remains.



When I perform an operation such as
1) $-8 mod 6 = 4$
And
2) $-6mod 8 = 2$



I understood part 2) because
on multiplying $8 cdot (-1) =-8$, the remainder becomes $+2$ (I feel that multiplying by $(-1)$ is correct, because in theory $-8$ is a smaller number than $-6$).



However part 1) does not make any sense to me



Could somebody please give me an explanation regarding the above (part 1)
Also do tell me if my way of thinking is wrong.



Thanks In advance.









share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Aug 15 at 5:48









Cornman

2,61721128




2,61721128










asked Aug 15 at 5:40









Agnay Srivastava

161




161







  • 1




    If it isn't $4$ then what non-negative integer between $0$ and $6$ would it be. It can't be $-8$ because $-8 < 0$. It can't be $-8 + 6 = -2$ because $-2 < 0$. It can't be $-8 + 6 + 6 + 6 = 10$ because $10 > 6$ so what other possible number can you get from $-8$ be adding or subtracting multiples of $6$? What is $-8 + 6 + 6$?
    – fleablood
    Aug 15 at 5:52












  • 1




    If it isn't $4$ then what non-negative integer between $0$ and $6$ would it be. It can't be $-8$ because $-8 < 0$. It can't be $-8 + 6 = -2$ because $-2 < 0$. It can't be $-8 + 6 + 6 + 6 = 10$ because $10 > 6$ so what other possible number can you get from $-8$ be adding or subtracting multiples of $6$? What is $-8 + 6 + 6$?
    – fleablood
    Aug 15 at 5:52







1




1




If it isn't $4$ then what non-negative integer between $0$ and $6$ would it be. It can't be $-8$ because $-8 < 0$. It can't be $-8 + 6 = -2$ because $-2 < 0$. It can't be $-8 + 6 + 6 + 6 = 10$ because $10 > 6$ so what other possible number can you get from $-8$ be adding or subtracting multiples of $6$? What is $-8 + 6 + 6$?
– fleablood
Aug 15 at 5:52




If it isn't $4$ then what non-negative integer between $0$ and $6$ would it be. It can't be $-8$ because $-8 < 0$. It can't be $-8 + 6 = -2$ because $-2 < 0$. It can't be $-8 + 6 + 6 + 6 = 10$ because $10 > 6$ so what other possible number can you get from $-8$ be adding or subtracting multiples of $6$? What is $-8 + 6 + 6$?
– fleablood
Aug 15 at 5:52










5 Answers
5






active

oldest

votes

















up vote
2
down vote













For every integer $m$ there are are unique integers $q$ and $r$ where $m = 6q + r$ and $0 le r < 6$. In the case of $m = -8$ the $q= -2$ and $r = 4$ because $-8 = 6(-2) + 4$.



If the remainder has to be an integer $r$ so that $0 le r < n-1$ then $- 8 equiv 4 mod 6$ because $-8 + 2* 6 = 4$. $4$ is the ONLY possible integer between $0$ and $6$ that you can get to from $8$ by adding or subtracting multiples of $6$.






share|cite|improve this answer



























    up vote
    0
    down vote













    $-8mod 6=4$, because $-8+6+6=4$.



    Viewing modulus as division with remainder is completly fine.
    Division with remainder works as follows. For $q,pinmathbbZ$ you have



    $p=kcdot q+r$ where $r$ is our remainder and it is $0leq r<|k|$. Therefor we search the smallest not-negativ number $r$. And then you can view the calculation above as statet.



    You can simply add 6 to -8 until you are the first time not-negativ. Which is in this case $4$. Hence the remainder is $4$.






    share|cite|improve this answer



























      up vote
      0
      down vote













      $4$ is the unique number in $0,1,2,3,4,5$ such that it differs from $-8$ by a multiple of $6$, namely $-8=(-2)cdot 6+4$.






      share|cite|improve this answer



























        up vote
        0
        down vote













        Not sure how familiar with modular arithmetic you are, but deriving a few basic results and appealing directly to definitions, those results become much more obvious:




        Proposition 1.1:
        For any two integers $a,b$, with $a gt 0$, there exist integers $q,r$ such that $$ b=qa +r , qquad 0 leq r lt a.$$




        Proof:



        Consider the rational number $fracba$. There exists a unique integer $q$ such that $$q leq fracba lt q +1$$
        $$implies qa leq b lt qa + a$$
        $$implies 0 leq b - qa lt a,$$
        and, letting $r=b - qa $, the result follows.



        $square$




        Definition 1.2:
        Let $a,b in mathbbZ$. We say $a$ divides $b$, if, for some integer $c$, $$b=ac.$$




        $quad$




        Definition 1.3:
        Let $m$ be a positive integer. For any $a,b in mathbbZ$, if $m$ divides $a-b$, we write $a equiv b pmodm$.




        $quad$




        Proposition 1.4:
        Every integer is congruent to exactly one of the integers $0,1,2 cdots, m-1$ $pmodm$.




        Proof:



        Note that $$a equiv b pmodm iff a-b=qm,$$ for some integer $q$, and so Proposition 1.4 follows immediately from Proposition 1.1.



        $square$



        Evaluating the example in your question, by Proposition 1.4, $-8$ is congruent to exactly one of the integers $0,1, 2,3,4,5, pmod6$.



        Now, it is clear that $-8=-2 cdot 6 + 4$ and so $$-8 equiv 4 pmod6,$$ or, in your notation $$-8pmod6=4.$$






        share|cite|improve this answer





























          up vote
          0
          down vote













          In systems for performing integer arithmetic, one typically has a pair of operators:



          • $a mathbinmathrmdiv b$ returns an integer estimating the quotient of $a/b$ (some amount of rounding required)

          • $a mathbinmathrmrem b$ returns a 'reduced' number that is congruent to $a$, modulo $b$

          (mod is a common symbol for the latter operator)



          There are a lot of choices to make regarding the fine details of these operations, but they are almost universally chosen to satisfy the given equation:



          $$a = b cdot (a mathbinmathrmdiv b) + (a mathbinmathrmrem b)$$



          which is the condition for the pair of values to be the result of 'division with remainder'.



          Some common examples of how to make this choice are:



          • Always round towards zero when computing $(a mathbinmathrmdiv b)$

          • Always round down when computing $(a mathbinmathrmdiv b)$

          • Always have $0 leq (a mathbinmathrmrem b) < mathbinmathrmabs(b)$

          It looks like your source is using the last of these three conventions.



          Occasionally you even see more relaxed conventions; e.g. there are applications for things like



          • Give me any remainder satisfying $-mathrmabs(b) < (a mathbinmathrmrem b) < mathrmabs(b)$

          • Give me any remainder satisfying $0 leq a mathbinmathrmrem b < 4 cdot mathrmabs(b)$

          • You can return any value for $a mathbinmathrmdiv b$ that is within 2 units of the true quotient $a/b$





          share|cite|improve this answer






















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "69"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2883235%2fmodulus-of-negative-numbers%23new-answer', 'question_page');

            );

            Post as a guest






























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            For every integer $m$ there are are unique integers $q$ and $r$ where $m = 6q + r$ and $0 le r < 6$. In the case of $m = -8$ the $q= -2$ and $r = 4$ because $-8 = 6(-2) + 4$.



            If the remainder has to be an integer $r$ so that $0 le r < n-1$ then $- 8 equiv 4 mod 6$ because $-8 + 2* 6 = 4$. $4$ is the ONLY possible integer between $0$ and $6$ that you can get to from $8$ by adding or subtracting multiples of $6$.






            share|cite|improve this answer
























              up vote
              2
              down vote













              For every integer $m$ there are are unique integers $q$ and $r$ where $m = 6q + r$ and $0 le r < 6$. In the case of $m = -8$ the $q= -2$ and $r = 4$ because $-8 = 6(-2) + 4$.



              If the remainder has to be an integer $r$ so that $0 le r < n-1$ then $- 8 equiv 4 mod 6$ because $-8 + 2* 6 = 4$. $4$ is the ONLY possible integer between $0$ and $6$ that you can get to from $8$ by adding or subtracting multiples of $6$.






              share|cite|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                For every integer $m$ there are are unique integers $q$ and $r$ where $m = 6q + r$ and $0 le r < 6$. In the case of $m = -8$ the $q= -2$ and $r = 4$ because $-8 = 6(-2) + 4$.



                If the remainder has to be an integer $r$ so that $0 le r < n-1$ then $- 8 equiv 4 mod 6$ because $-8 + 2* 6 = 4$. $4$ is the ONLY possible integer between $0$ and $6$ that you can get to from $8$ by adding or subtracting multiples of $6$.






                share|cite|improve this answer












                For every integer $m$ there are are unique integers $q$ and $r$ where $m = 6q + r$ and $0 le r < 6$. In the case of $m = -8$ the $q= -2$ and $r = 4$ because $-8 = 6(-2) + 4$.



                If the remainder has to be an integer $r$ so that $0 le r < n-1$ then $- 8 equiv 4 mod 6$ because $-8 + 2* 6 = 4$. $4$ is the ONLY possible integer between $0$ and $6$ that you can get to from $8$ by adding or subtracting multiples of $6$.







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Aug 15 at 5:47









                fleablood

                60.7k22575




                60.7k22575




















                    up vote
                    0
                    down vote













                    $-8mod 6=4$, because $-8+6+6=4$.



                    Viewing modulus as division with remainder is completly fine.
                    Division with remainder works as follows. For $q,pinmathbbZ$ you have



                    $p=kcdot q+r$ where $r$ is our remainder and it is $0leq r<|k|$. Therefor we search the smallest not-negativ number $r$. And then you can view the calculation above as statet.



                    You can simply add 6 to -8 until you are the first time not-negativ. Which is in this case $4$. Hence the remainder is $4$.






                    share|cite|improve this answer
























                      up vote
                      0
                      down vote













                      $-8mod 6=4$, because $-8+6+6=4$.



                      Viewing modulus as division with remainder is completly fine.
                      Division with remainder works as follows. For $q,pinmathbbZ$ you have



                      $p=kcdot q+r$ where $r$ is our remainder and it is $0leq r<|k|$. Therefor we search the smallest not-negativ number $r$. And then you can view the calculation above as statet.



                      You can simply add 6 to -8 until you are the first time not-negativ. Which is in this case $4$. Hence the remainder is $4$.






                      share|cite|improve this answer






















                        up vote
                        0
                        down vote










                        up vote
                        0
                        down vote









                        $-8mod 6=4$, because $-8+6+6=4$.



                        Viewing modulus as division with remainder is completly fine.
                        Division with remainder works as follows. For $q,pinmathbbZ$ you have



                        $p=kcdot q+r$ where $r$ is our remainder and it is $0leq r<|k|$. Therefor we search the smallest not-negativ number $r$. And then you can view the calculation above as statet.



                        You can simply add 6 to -8 until you are the first time not-negativ. Which is in this case $4$. Hence the remainder is $4$.






                        share|cite|improve this answer












                        $-8mod 6=4$, because $-8+6+6=4$.



                        Viewing modulus as division with remainder is completly fine.
                        Division with remainder works as follows. For $q,pinmathbbZ$ you have



                        $p=kcdot q+r$ where $r$ is our remainder and it is $0leq r<|k|$. Therefor we search the smallest not-negativ number $r$. And then you can view the calculation above as statet.



                        You can simply add 6 to -8 until you are the first time not-negativ. Which is in this case $4$. Hence the remainder is $4$.







                        share|cite|improve this answer












                        share|cite|improve this answer



                        share|cite|improve this answer










                        answered Aug 15 at 5:43









                        Cornman

                        2,61721128




                        2,61721128




















                            up vote
                            0
                            down vote













                            $4$ is the unique number in $0,1,2,3,4,5$ such that it differs from $-8$ by a multiple of $6$, namely $-8=(-2)cdot 6+4$.






                            share|cite|improve this answer
























                              up vote
                              0
                              down vote













                              $4$ is the unique number in $0,1,2,3,4,5$ such that it differs from $-8$ by a multiple of $6$, namely $-8=(-2)cdot 6+4$.






                              share|cite|improve this answer






















                                up vote
                                0
                                down vote










                                up vote
                                0
                                down vote









                                $4$ is the unique number in $0,1,2,3,4,5$ such that it differs from $-8$ by a multiple of $6$, namely $-8=(-2)cdot 6+4$.






                                share|cite|improve this answer












                                $4$ is the unique number in $0,1,2,3,4,5$ such that it differs from $-8$ by a multiple of $6$, namely $-8=(-2)cdot 6+4$.







                                share|cite|improve this answer












                                share|cite|improve this answer



                                share|cite|improve this answer










                                answered Aug 15 at 5:44









                                Hagen von Eitzen

                                265k21258477




                                265k21258477




















                                    up vote
                                    0
                                    down vote













                                    Not sure how familiar with modular arithmetic you are, but deriving a few basic results and appealing directly to definitions, those results become much more obvious:




                                    Proposition 1.1:
                                    For any two integers $a,b$, with $a gt 0$, there exist integers $q,r$ such that $$ b=qa +r , qquad 0 leq r lt a.$$




                                    Proof:



                                    Consider the rational number $fracba$. There exists a unique integer $q$ such that $$q leq fracba lt q +1$$
                                    $$implies qa leq b lt qa + a$$
                                    $$implies 0 leq b - qa lt a,$$
                                    and, letting $r=b - qa $, the result follows.



                                    $square$




                                    Definition 1.2:
                                    Let $a,b in mathbbZ$. We say $a$ divides $b$, if, for some integer $c$, $$b=ac.$$




                                    $quad$




                                    Definition 1.3:
                                    Let $m$ be a positive integer. For any $a,b in mathbbZ$, if $m$ divides $a-b$, we write $a equiv b pmodm$.




                                    $quad$




                                    Proposition 1.4:
                                    Every integer is congruent to exactly one of the integers $0,1,2 cdots, m-1$ $pmodm$.




                                    Proof:



                                    Note that $$a equiv b pmodm iff a-b=qm,$$ for some integer $q$, and so Proposition 1.4 follows immediately from Proposition 1.1.



                                    $square$



                                    Evaluating the example in your question, by Proposition 1.4, $-8$ is congruent to exactly one of the integers $0,1, 2,3,4,5, pmod6$.



                                    Now, it is clear that $-8=-2 cdot 6 + 4$ and so $$-8 equiv 4 pmod6,$$ or, in your notation $$-8pmod6=4.$$






                                    share|cite|improve this answer


























                                      up vote
                                      0
                                      down vote













                                      Not sure how familiar with modular arithmetic you are, but deriving a few basic results and appealing directly to definitions, those results become much more obvious:




                                      Proposition 1.1:
                                      For any two integers $a,b$, with $a gt 0$, there exist integers $q,r$ such that $$ b=qa +r , qquad 0 leq r lt a.$$




                                      Proof:



                                      Consider the rational number $fracba$. There exists a unique integer $q$ such that $$q leq fracba lt q +1$$
                                      $$implies qa leq b lt qa + a$$
                                      $$implies 0 leq b - qa lt a,$$
                                      and, letting $r=b - qa $, the result follows.



                                      $square$




                                      Definition 1.2:
                                      Let $a,b in mathbbZ$. We say $a$ divides $b$, if, for some integer $c$, $$b=ac.$$




                                      $quad$




                                      Definition 1.3:
                                      Let $m$ be a positive integer. For any $a,b in mathbbZ$, if $m$ divides $a-b$, we write $a equiv b pmodm$.




                                      $quad$




                                      Proposition 1.4:
                                      Every integer is congruent to exactly one of the integers $0,1,2 cdots, m-1$ $pmodm$.




                                      Proof:



                                      Note that $$a equiv b pmodm iff a-b=qm,$$ for some integer $q$, and so Proposition 1.4 follows immediately from Proposition 1.1.



                                      $square$



                                      Evaluating the example in your question, by Proposition 1.4, $-8$ is congruent to exactly one of the integers $0,1, 2,3,4,5, pmod6$.



                                      Now, it is clear that $-8=-2 cdot 6 + 4$ and so $$-8 equiv 4 pmod6,$$ or, in your notation $$-8pmod6=4.$$






                                      share|cite|improve this answer
























                                        up vote
                                        0
                                        down vote










                                        up vote
                                        0
                                        down vote









                                        Not sure how familiar with modular arithmetic you are, but deriving a few basic results and appealing directly to definitions, those results become much more obvious:




                                        Proposition 1.1:
                                        For any two integers $a,b$, with $a gt 0$, there exist integers $q,r$ such that $$ b=qa +r , qquad 0 leq r lt a.$$




                                        Proof:



                                        Consider the rational number $fracba$. There exists a unique integer $q$ such that $$q leq fracba lt q +1$$
                                        $$implies qa leq b lt qa + a$$
                                        $$implies 0 leq b - qa lt a,$$
                                        and, letting $r=b - qa $, the result follows.



                                        $square$




                                        Definition 1.2:
                                        Let $a,b in mathbbZ$. We say $a$ divides $b$, if, for some integer $c$, $$b=ac.$$




                                        $quad$




                                        Definition 1.3:
                                        Let $m$ be a positive integer. For any $a,b in mathbbZ$, if $m$ divides $a-b$, we write $a equiv b pmodm$.




                                        $quad$




                                        Proposition 1.4:
                                        Every integer is congruent to exactly one of the integers $0,1,2 cdots, m-1$ $pmodm$.




                                        Proof:



                                        Note that $$a equiv b pmodm iff a-b=qm,$$ for some integer $q$, and so Proposition 1.4 follows immediately from Proposition 1.1.



                                        $square$



                                        Evaluating the example in your question, by Proposition 1.4, $-8$ is congruent to exactly one of the integers $0,1, 2,3,4,5, pmod6$.



                                        Now, it is clear that $-8=-2 cdot 6 + 4$ and so $$-8 equiv 4 pmod6,$$ or, in your notation $$-8pmod6=4.$$






                                        share|cite|improve this answer














                                        Not sure how familiar with modular arithmetic you are, but deriving a few basic results and appealing directly to definitions, those results become much more obvious:




                                        Proposition 1.1:
                                        For any two integers $a,b$, with $a gt 0$, there exist integers $q,r$ such that $$ b=qa +r , qquad 0 leq r lt a.$$




                                        Proof:



                                        Consider the rational number $fracba$. There exists a unique integer $q$ such that $$q leq fracba lt q +1$$
                                        $$implies qa leq b lt qa + a$$
                                        $$implies 0 leq b - qa lt a,$$
                                        and, letting $r=b - qa $, the result follows.



                                        $square$




                                        Definition 1.2:
                                        Let $a,b in mathbbZ$. We say $a$ divides $b$, if, for some integer $c$, $$b=ac.$$




                                        $quad$




                                        Definition 1.3:
                                        Let $m$ be a positive integer. For any $a,b in mathbbZ$, if $m$ divides $a-b$, we write $a equiv b pmodm$.




                                        $quad$




                                        Proposition 1.4:
                                        Every integer is congruent to exactly one of the integers $0,1,2 cdots, m-1$ $pmodm$.




                                        Proof:



                                        Note that $$a equiv b pmodm iff a-b=qm,$$ for some integer $q$, and so Proposition 1.4 follows immediately from Proposition 1.1.



                                        $square$



                                        Evaluating the example in your question, by Proposition 1.4, $-8$ is congruent to exactly one of the integers $0,1, 2,3,4,5, pmod6$.



                                        Now, it is clear that $-8=-2 cdot 6 + 4$ and so $$-8 equiv 4 pmod6,$$ or, in your notation $$-8pmod6=4.$$







                                        share|cite|improve this answer














                                        share|cite|improve this answer



                                        share|cite|improve this answer








                                        edited Aug 15 at 7:58

























                                        answered Aug 15 at 7:47









                                        Moed Pol Bollo

                                        25228




                                        25228




















                                            up vote
                                            0
                                            down vote













                                            In systems for performing integer arithmetic, one typically has a pair of operators:



                                            • $a mathbinmathrmdiv b$ returns an integer estimating the quotient of $a/b$ (some amount of rounding required)

                                            • $a mathbinmathrmrem b$ returns a 'reduced' number that is congruent to $a$, modulo $b$

                                            (mod is a common symbol for the latter operator)



                                            There are a lot of choices to make regarding the fine details of these operations, but they are almost universally chosen to satisfy the given equation:



                                            $$a = b cdot (a mathbinmathrmdiv b) + (a mathbinmathrmrem b)$$



                                            which is the condition for the pair of values to be the result of 'division with remainder'.



                                            Some common examples of how to make this choice are:



                                            • Always round towards zero when computing $(a mathbinmathrmdiv b)$

                                            • Always round down when computing $(a mathbinmathrmdiv b)$

                                            • Always have $0 leq (a mathbinmathrmrem b) < mathbinmathrmabs(b)$

                                            It looks like your source is using the last of these three conventions.



                                            Occasionally you even see more relaxed conventions; e.g. there are applications for things like



                                            • Give me any remainder satisfying $-mathrmabs(b) < (a mathbinmathrmrem b) < mathrmabs(b)$

                                            • Give me any remainder satisfying $0 leq a mathbinmathrmrem b < 4 cdot mathrmabs(b)$

                                            • You can return any value for $a mathbinmathrmdiv b$ that is within 2 units of the true quotient $a/b$





                                            share|cite|improve this answer


























                                              up vote
                                              0
                                              down vote













                                              In systems for performing integer arithmetic, one typically has a pair of operators:



                                              • $a mathbinmathrmdiv b$ returns an integer estimating the quotient of $a/b$ (some amount of rounding required)

                                              • $a mathbinmathrmrem b$ returns a 'reduced' number that is congruent to $a$, modulo $b$

                                              (mod is a common symbol for the latter operator)



                                              There are a lot of choices to make regarding the fine details of these operations, but they are almost universally chosen to satisfy the given equation:



                                              $$a = b cdot (a mathbinmathrmdiv b) + (a mathbinmathrmrem b)$$



                                              which is the condition for the pair of values to be the result of 'division with remainder'.



                                              Some common examples of how to make this choice are:



                                              • Always round towards zero when computing $(a mathbinmathrmdiv b)$

                                              • Always round down when computing $(a mathbinmathrmdiv b)$

                                              • Always have $0 leq (a mathbinmathrmrem b) < mathbinmathrmabs(b)$

                                              It looks like your source is using the last of these three conventions.



                                              Occasionally you even see more relaxed conventions; e.g. there are applications for things like



                                              • Give me any remainder satisfying $-mathrmabs(b) < (a mathbinmathrmrem b) < mathrmabs(b)$

                                              • Give me any remainder satisfying $0 leq a mathbinmathrmrem b < 4 cdot mathrmabs(b)$

                                              • You can return any value for $a mathbinmathrmdiv b$ that is within 2 units of the true quotient $a/b$





                                              share|cite|improve this answer
























                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                In systems for performing integer arithmetic, one typically has a pair of operators:



                                                • $a mathbinmathrmdiv b$ returns an integer estimating the quotient of $a/b$ (some amount of rounding required)

                                                • $a mathbinmathrmrem b$ returns a 'reduced' number that is congruent to $a$, modulo $b$

                                                (mod is a common symbol for the latter operator)



                                                There are a lot of choices to make regarding the fine details of these operations, but they are almost universally chosen to satisfy the given equation:



                                                $$a = b cdot (a mathbinmathrmdiv b) + (a mathbinmathrmrem b)$$



                                                which is the condition for the pair of values to be the result of 'division with remainder'.



                                                Some common examples of how to make this choice are:



                                                • Always round towards zero when computing $(a mathbinmathrmdiv b)$

                                                • Always round down when computing $(a mathbinmathrmdiv b)$

                                                • Always have $0 leq (a mathbinmathrmrem b) < mathbinmathrmabs(b)$

                                                It looks like your source is using the last of these three conventions.



                                                Occasionally you even see more relaxed conventions; e.g. there are applications for things like



                                                • Give me any remainder satisfying $-mathrmabs(b) < (a mathbinmathrmrem b) < mathrmabs(b)$

                                                • Give me any remainder satisfying $0 leq a mathbinmathrmrem b < 4 cdot mathrmabs(b)$

                                                • You can return any value for $a mathbinmathrmdiv b$ that is within 2 units of the true quotient $a/b$





                                                share|cite|improve this answer














                                                In systems for performing integer arithmetic, one typically has a pair of operators:



                                                • $a mathbinmathrmdiv b$ returns an integer estimating the quotient of $a/b$ (some amount of rounding required)

                                                • $a mathbinmathrmrem b$ returns a 'reduced' number that is congruent to $a$, modulo $b$

                                                (mod is a common symbol for the latter operator)



                                                There are a lot of choices to make regarding the fine details of these operations, but they are almost universally chosen to satisfy the given equation:



                                                $$a = b cdot (a mathbinmathrmdiv b) + (a mathbinmathrmrem b)$$



                                                which is the condition for the pair of values to be the result of 'division with remainder'.



                                                Some common examples of how to make this choice are:



                                                • Always round towards zero when computing $(a mathbinmathrmdiv b)$

                                                • Always round down when computing $(a mathbinmathrmdiv b)$

                                                • Always have $0 leq (a mathbinmathrmrem b) < mathbinmathrmabs(b)$

                                                It looks like your source is using the last of these three conventions.



                                                Occasionally you even see more relaxed conventions; e.g. there are applications for things like



                                                • Give me any remainder satisfying $-mathrmabs(b) < (a mathbinmathrmrem b) < mathrmabs(b)$

                                                • Give me any remainder satisfying $0 leq a mathbinmathrmrem b < 4 cdot mathrmabs(b)$

                                                • You can return any value for $a mathbinmathrmdiv b$ that is within 2 units of the true quotient $a/b$






                                                share|cite|improve this answer














                                                share|cite|improve this answer



                                                share|cite|improve this answer








                                                edited Aug 15 at 8:13

























                                                answered Aug 15 at 8:06









                                                Hurkyl

                                                108k9113254




                                                108k9113254






















                                                     

                                                    draft saved


                                                    draft discarded


























                                                     


                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2883235%2fmodulus-of-negative-numbers%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest













































































                                                    這個網誌中的熱門文章

                                                    tkz-euclide: tkzDrawCircle[R] not working

                                                    How to combine Bézier curves to a surface?

                                                    1st Magritte Awards