So, as I understand it, the ADA programming language provides 2 remainder operators (along with a whole mess of allowable overloading for most operators). I'm having difficulty grasping the difference between the 2 remainder operators. I looked over this WikiBooks page I came across, but I don't think I'm making the light bulb turn on yet.

WikiBooks ADA Operators

Can anyone explain this a little better to me?

# Difference in ADA Remainder Operators?

Page 1 of 1## 2 Replies - 2545 Views - Last Post: 20 November 2013 - 04:59 AM

##
**Replies To:** Difference in ADA Remainder Operators?

### #2

## Re: Difference in ADA Remainder Operators?

Posted 18 November 2013 - 01:48 PM

A mod B and A rem B are the same for positive integers A. The difference occurs when A is negative. mod will continue the looping pattern leaving only positive results. rem on the other hand will give negative results that are more of a reflection of the positive A's

for example

The reason for this is that mod technically returns a label representing a group of numbers. Every nth number is congruent (mod n). We say that -6,-3,0,3,and 6 are congruent (mod 3) thus they belong to the same congruency class. It is somewhat convenient to chose 0 for the label of this class. Remainder is just the calculation of what is left over after integer division is performed. So a negative number will have a negative leftover.

for example

N |-6|-5|-4|-3|-2|-1| 0| 1| 2| 3| 4| 5| 6| ---------------------------------------------- N mod 3| 0| 1| 2| 0| 1| 2| 0| 1| 2| 0| 1| 2| 0| ---------------------------------------------- N rem 3| 0|-2|-1| 0|-2|-1| 0| 1| 2| 0| 1| 2| 0|

The reason for this is that mod technically returns a label representing a group of numbers. Every nth number is congruent (mod n). We say that -6,-3,0,3,and 6 are congruent (mod 3) thus they belong to the same congruency class. It is somewhat convenient to chose 0 for the label of this class. Remainder is just the calculation of what is left over after integer division is performed. So a negative number will have a negative leftover.

This post has been edited by **mojo666**: 18 November 2013 - 01:52 PM

### #3

## Re: Difference in ADA Remainder Operators?

Posted 20 November 2013 - 04:59 AM

Nice. Someone else knows the difference between reminder and modulus too.

I have been yelling about that on many C-forums, when people don't realize that "%" is reminder, not modulus.

In C (and C++) the "%" operator is called "mod" or "modulus", but the explanation is usually like "returns the remainder of expr1 divided by expr2".

I have been yelling about that on many C-forums, when people don't realize that "%" is reminder, not modulus.

In C (and C++) the "%" operator is called "mod" or "modulus", but the explanation is usually like "returns the remainder of expr1 divided by expr2".

Page 1 of 1