Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2007-06-02 08:03:32

Math-e-matics
Member
Registered: 2007-06-02
Posts: 1

Are remainders always positive or can they be negative.

When doing a modulus division on a negative number can/should the remainder be negative.

Example

-25 Mod 6

Is it -4 with a remainder of 1 or
Is it -4 with a remainder of -1 ?

What is -5 mod 6

Is it 0 with a remainder of -5 or
Is it 0 with a remainder of 5 ?

Offline

#2 2007-06-02 08:45:10

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Are remainders always positive or can they be negative.

The mod of a number has to be positive, so you need to engineer the answer so that that happens.

For example, -25 ÷ 6 is not -4 r-1, but instead -5 r 5. So -25 mod 6 = 5.
Similarly, -5 ÷ 6 = -1 r1, so -5 mod 6 = 1.


Why did the vector cross the road?
It wanted to be normal.

Offline

#3 2007-06-02 08:45:41

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Are remainders always positive or can they be negative.

As it turns out, you can either have positive or negative remainders for anything, and everything turns out to work the same way.  For example, you could use the Euclidean algorithm with negative remainders, it would be a bit awkward and you'd have to modify it a bit, but it would work.

But when we talk about modulus, we are typically referring to equivalence classes being represented by positive numbers (there are various reasons for this, most come out of number theory).

However, remember the key thing about modulus.  It has to divide.


-25 Mod 6

Is it -4 with a remainder of 1 or
Is it -4 with a remainder of -1 ?

It should be either -5 with a remainder of 5 or -4 with a remainder of -1.  Typically, we go with the first.  So we say that -25 = 5 (mod 6).


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#4 2007-06-02 14:14:33

George,Y
Member
Registered: 2006-03-12
Posts: 1,379

Re: Are remainders always positive or can they be negative.

Yes, for convenience we use a remainder satisfying 0<remainder<divident.


X'(y-Xβ)=0

Offline

Board footer

Powered by FluxBB