Positive or negative remainder

Click For Summary

Discussion Overview

The discussion revolves around the concept of remainders in division, specifically whether a negative number can be considered a valid remainder. Participants explore different conventions and definitions related to remainders when dividing integers, particularly in the context of the expression -23 = 5(-4) - 3.

Discussion Character

  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants argue that -3 can be a remainder, as it belongs to the equivalence class of 23 when divided by 5.
  • Others assert that the remainder is typically defined to be between 0 and N-1 inclusive, suggesting that -2 is the appropriate representative in this case.
  • A participant notes that the interpretation of remainders can depend on the convention used for integer division, highlighting differences in programming languages and mathematical contexts.
  • There is mention of two different interpretations of -23 divided by 5, with one yielding a remainder of -3 and the other yielding a remainder of 2, depending on the division convention adopted.

Areas of Agreement / Disagreement

Participants do not reach a consensus on whether -3 can be considered a valid remainder, as multiple competing views remain regarding the definition and conventions of remainders in division.

Contextual Notes

The discussion highlights the dependence on definitions and conventions for remainders, particularly in relation to integer division and equivalence classes.

Ling Min Hao
Messages
22
Reaction score
0
Is 23 = 5(-4)-3 gives a remainder -3 when divided by 5 ? is this statement true ? some of my colleagues said that remainder cannot be negative numbers as definition but I am doubt that can -3 be a remainder too?
 
Physics news on Phys.org
Ling Min Hao said:
Is 23 = 5(-4)-3 gives a remainder -3 when divided by 5 ? is this statement true ? some of my colleagues said that remainder cannot be negative numbers as definition but I am doubt that can -3 be a remainder too?
Usually we consider entire equivalence classes in such cases: Every single element of ##\{\ldots -13, -8, -3, 2, 7 , 12, \ldots\}## belongs to the same remainder of a division by ##5##. We then define all five possible classes
##\{\ldots -15, -10, -5, 0, 5, 10, \ldots\}##
##\{\ldots -14, -9, -4, 1, 6, 11, \ldots\}##
##\{\ldots -13, -8, -3, 2, 7, 12, \ldots\}##
##\{\ldots -12, -7, -2, 3, 8, 13, \ldots\}##
##\{\ldots -11, -6, -1, 4, 9, 14, \ldots\}##
as elements of a new set with five elements ##\{ \; \{\ldots -15, -10, -5, 0, 5, 10, \ldots\}\, , \, \{\ldots -14, -9, -4, 1, 6, 11, \ldots\}\, , \, \ldots \}##.

This notation is a bit nasty to handle, so we choose one representative out of every set. E.g. ##\{[-15],[-9],[12],[3],[-1]\}## could be chosen, but this is still a bit messy to do calculations with. So the most convenient representation is ##\{[0],[1],[2],[3],[4]\}## with the non-negative remainders smaller than ##5##. However, this is only a convention. ##-3## is a remainder, too, belonging to the class ##[2]##. So the answer to your questions is: The statement is true, as all integers are remainders.
 
The remainder is usually required to be between 0 and N-1 inclusive. 23 and -2 (not -3) are in the same equivalence class. This can also be written as 23 = -2 mod 5.
 
mfb said:
The remainder is usually required to be between 0 and N-1 inclusive. 23 and -2 (not -3) are in the same equivalence class. This can also be written as 23 = -2 mod 5.

Sorry it should be -23 = 5(-4) - 3 , so in conclusion is, this statement true ?
 
Ling Min Hao said:
Sorry it should be -23 = 5(-4) - 3 , so in conclusion is, this statement true ?
"-23 divided by 5 is -4 with a remainder of -3". I would consider that statement true.
"-23 divided by 5 is -5 with a remainder of 2". I would also consider that statement to be true.

The convention you use for integer division will determine which of those statements is conventional and which is unconventional.

In many programming languages, integer division follows a "truncate toward zero" convention. For instance, in Ada, -23/5 = -4. The "rem" operator then gives the remainder. So -23 rem 5 = -3.

If one adopts a convention that integer division (by a positive number) truncates toward negative infinity then one would get a different conventional remainder. -23/5 would be -5 and -23 mod 5 would be +2. The Ada "mod" operator uses this convention.

In mathematics, one typically adopts the line of reasoning given by @fresh_42 in post#2 above. The canonical exemplar in the equivalence class of possible remainders is normally the one in the range from 0 to divisor - 1.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
7
Views
2K
Replies
6
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
Replies
22
Views
4K
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K