示例#1
0
 public void Inv(GXBigInteger value)
 {
     if (!IsZero)
     {
         GXBigInteger lm  = new GXBigInteger(1);
         GXBigInteger hm  = new GXBigInteger(0);
         GXBigInteger low = new GXBigInteger(this);
         low.Mod(value);
         GXBigInteger high = new GXBigInteger(value);
         while (!(low.IsZero || low.IsOne))
         {
             GXBigInteger r = new GXBigInteger(high);
             r.Div(low);
             GXBigInteger tmp = new GXBigInteger(lm);
             tmp.Multiply(r);
             GXBigInteger nm = new GXBigInteger(hm);
             nm.Sub(tmp);
             tmp = new GXBigInteger(low);
             tmp.Multiply(r);
             high.Sub(tmp);
             // lm, low, hm, high = nm, new, lm, low
             tmp  = low;
             low  = new GXBigInteger(high);
             high = tmp;
             hm   = new GXBigInteger(lm);
             lm   = new GXBigInteger(nm);
         }
         Data     = lm.Data;
         negative = lm.negative;
         Mod(value);
     }
 }