Architecture

Can You Have A Negative Remainder When Dividing Negative Numbers

Closed.

You are watching: Can you have a negative remainder

This question does not meet nadechworld.comematics Stack Exchange guidelines. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for nadechworld.comematics Stack Exchange.

Closed 2 years ago.

*

*

​​​​There are two conventions, depending on whether you allow the remainder to be negative.

Either you don”t

$$-27 = -6 imes 5 + 3$$

or you do

$$-27 = -5 imes 5 + (-2)$$

Note that whatever convention you choose, the two possibilities for the remainder will always differ by $5$.

*

*

Per the Euclidean Algorithm:

$$-27 = underbrace{-6}_qcdot underbrace{5}_d + underbrace{3}_r$$

where $q$ is the quotient when $-27$ (dividend) is divided by the divisor $d=5$, and $r$ is the remainder. It is standard to represent the remainder $r$ such that $0 leq r lt ;d.$

*

There are various conventions for how to define the quotient and remainder for the division algorithm when extended from naturals to integers, i.e. the extension to negative integers.

The remainder is uniquely determined once one defines the quotient, and many conventions are based on a choice of which direction to round the quotient, e.g. towards $,0,$ or, towards the nearest integer, or towards $,pminfty.$ Some programming languages provide all of the possibilities, e.g. see the floor, ceiling, round, truncate functions in Common Lisp.

See more: Endless Dungeon Of The Endless Local Co Op, Endless Dungeon

A web search will turn up further discussion of such conventions in many places, e.g. on Wikipedia and D. Leijen, Division and Modulus for Computer Scientists.

Be sure to grok the difference between $!mod!$ as a (remainder) operation vs. (congruence) relation, which is discussed at length in this answer.

Share
Cite
Follow
edited Apr 28 at 19:47
answered Dec 31 “13 at 18:00
Bill DubuqueBill Dubuque
252k3636 gold badges255255 silver badges818818 bronze badges
$endgroup$
1
Add a comment |
1
$egingroup$
Let $m$ be a negative integer $ 0$.

Proposition: There exist unique integers $q$ and $r$ satisfying the following conditions:

$q le 0$

$0 le -r lt b;$ (so $r$ is a nonpositive integer)

$m = qb + r$

The proof is left as an exercise for the interested reader.

See more: How To Do A Miracle Whip On Skate 3 9;T Be So Mayo Achievement

There is nothing heretical about this. To some it might even be the more natural way to perform Euclidean Division on negative numbers. Why?

You are making great progress working with integers and are using them to measure lengths. You work with many rulers using “tick” marks, but have to select the ruler with the required ‘Ticks per Unit Length Precision Granularity’.

You know if your unit length has 5 ticks and something is 27 ticks long, that you measure it on the ruler at (5*5 + 2) ticks, or

27 ticks / (5 ticks/Units) = $(5 + frac{2}{5})$ Units

*

You naturally do the same thing when measuring to the left (negative lengths).

The next day you get a bit more abstract and define the rational numbers. It turns out that your method is actually the way to represent a rational number as a mixed number. Just for fun, check out

How to Convert a Negative Mixed Number Into an Improper Fraction : Fractions 101

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button