There is a difference between modulus and remainder. For example:
-21
mod 4
is 3
because -21 + 4 x 6
is 3
.
But -21
divided by 4
gives -5
with a remainder of -1
.
For positive values, there is no difference.
More Related Contents:
- What is the "–>" operator in C/C++?
- "." or "->" C struct accessor [duplicate]
- Logic behind sizeof operator [duplicate]
- Not able to calculate in C.How do you calculate in C?
- Sum of the all the numbers between a and b [closed]
- What does the ??!??! operator do in C?
- The most efficient way to implement an integer based power function pow(int, int)
- What is short-circuit evaluation in C?
- Undefined reference to `sin` [duplicate]
- How do I determine the number of digits of an integer in C?
- Power by squaring for negative exponents
- What does i = (i, ++i, 1) + 1; do?
- Explain this snippet which finds the maximum of two integers without using if-else or any other comparison operator?
- Using M_PI with C89 standard
- Representing integers in doubles
- Compute fast log base 2 ceiling
- Are floating point operations in C associative?
- C – How to implement Set data structure?
- C: how to break apart a multi digit number into separate variables?
- Why does gdb evaluate sqrt(3) to 0?
- How can I calculate divide and modulo for integers in C#?
- To the power of in C? [duplicate]
- How does this bitwise operation check for a power of 2?
- log2 not found in my math.h?
- In C, what is the difference between `&function` and `function` when passed as arguments?
- How to use % operator for float values in c
- Evaluate Mathematical Function from String [closed]
- How sqrt() of GCC works after compiled? Which method of root is used? Newton-Raphson?
- Does *p++ increment after dereferencing? [duplicate]
- Algorithm to pick values from array that sum closest to a target value?