Пример #1
0
        /* this*=c mod Modulus, where c is a small int */
        public void IMul(int c)
        {
            //		norm();
            bool s = false;

            if (c < 0)
            {
                c = -c;
                s = true;
            }

            if (MODTYPE == PSEUDO_MERSENNE || MODTYPE == GENERALISED_MERSENNE)
            {
                DBIG d = x.PXMul(c);
                x.Copy(Mod(d));
                XES = 2;
            }
            else
            {
                if (XES * c <= FEXCESS)
                {
                    x.PMul(c);
                    XES *= c;
                }
                else
                {                 // this is not good
                    FP n = new FP(c);
                    Mul(n);
                }
            }

            /*
             *              if (c<=BIG.NEXCESS && XES*c<=FEXCESS)
             *              {
             *                      x.imul(c);
             *                      XES*=c;
             *                      x.norm();
             *              }
             *              else
             *              {
             *                      DBIG d=x.pxmul(c);
             *                      x.copy(mod(d));
             *                      XES=2;
             *              }
             */
            if (s)
            {
                Neg();
                Norm();
            }
        }