From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- libmp/port/mpmod.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 libmp/port/mpmod.c (limited to 'libmp/port/mpmod.c') diff --git a/libmp/port/mpmod.c b/libmp/port/mpmod.c new file mode 100644 index 00000000..91bebfa2 --- /dev/null +++ b/libmp/port/mpmod.c @@ -0,0 +1,15 @@ +#include "os.h" +#include +#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); +} -- cgit v1.2.3