a
This commit is contained in:
15
libmp/mpmod.c
Normal file
15
libmp/mpmod.c
Normal file
@ -0,0 +1,15 @@
|
||||
#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);
|
||||
}
|
Reference in New Issue
Block a user