Modulo operation
From Maths
Revision as of 17:48, 7 January 2018 by Alec (Talk | contribs) (Alec moved page Modulo opeartion to Modulo operation without leaving a redirect: Typo in title)
- Not to be confused with: Modulus operation - which is another name for absolute value
Definition
For a∈N0 and b∈N "a modulo b", written usually as a%b in most programming languages or using a mod(a,b) function is the remainder of dividing a by b.
Implementation
I write this page because I have used:
- a%b=(a−b⋅Floor(ab))
- Caveat:This only works for non-negative values! TODO: Proof?
- Caveat:This only works for non-negative values!
See also
Extensions
- What about negative numbers?
- 2.5 mod 1 is safely and obviously 0.5 - this is quite common.