Sign in
plan9port
/
plan9
/
08e793723cad1c7aed2e8cb16c8592aba5ad05e9
/
.
/
src
/
libmp
/
port
/
mpmod.c
blob: 409dd38f423fd8e014d7e0e3527739d249718c15 [
file
] [
log
] [
blame
]
#include
"os.h"
#include
<mp.h>
#include
"dat.h"
/* remainder = b mod m */
/* */
/* knuth, vol 2, pp 398-400 */
void
mpmod
(
mpint
*
b
,
mpint
*
m
,
mpint
*
remainder
)
{
mpdiv
(
b
,
m
,
nil
,
remainder
);
if
(
remainder
->
sign
<
0
)
mpadd
(
m
,
remainder
,
remainder
);
}