ref: 62389c8990cafb8e99ae29b2bccbcd100ce4c7f0
dir: /3rd/mp/mpmod.c/
#include "platform.h" #include "mp.h" void mpmod(mpint *x, mpint *n, mpint *r) { int sign; mpint *ns; sign = x->sign; ns = sign < 0 && n == r ? mpcopy(n) : n; mpdiv(x, n, nil, r); if(sign < 0){ mpmagsub(ns, r, r); if(ns != n) mpfree(ns); } }