The standard mathematical notation is that
a ≡ b (mod c)
and is read "a is congruent to b mod c".
This kind of stuff is actually useful, though it is most enjoyable when you play with Number Theory.
A common algorithm is to compute
Y ≡ Gx (mod P)
for cryptographic uses.
Other basic uses include the Chinese Remainder Theorem, etc.
To answer your question, yes, I could write
d = (a + b) % c
. But with big numbers time is often a factor. There are often ways to compute the answer more quickly than the straightforward method.
By overloading a biginteger () operator to play nice, I can use those functions while allowing a natural (mathematically speaking) syntax.
There are all kinds of ways to apply the optimized algorithms over the standard ones:
1 2 3 4 5 6 7
|
d = a.add_mod( b, c ); // single function call
d = a.add( b ).mod( c ); // stack-based delayed eval
d = (a + b).mod( c ); // same
d = a + b (mod c); // oooh! pretty!
|
The whole trick, of course, is that the argument to b() is two lexemes... "mod" and "c", one of which must evaluate to more or less nothing. I know of no other way to do RLM without macros.
Your response is telling me that it is probably a bad idea...