Add libmp.

This commit is contained in:
rsc 2004-03-21 14:06:38 +00:00
parent 498bb22174
commit b3f61791f1
37 changed files with 2415 additions and 0 deletions

15
src/libmp/port/mpmod.c Normal file
View 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);
}