ModPow() 공개 메소드

public ModPow ( BigInteger power, BigInteger mod ) : BigInteger
power BigInteger
mod BigInteger
리턴 BigInteger
예제 #1
0
파일: LongOps.cs 프로젝트: atczyc/ironruby
        public static object Power(BigInteger x, BigInteger y, BigInteger z) {
            if (y < BigInteger.Zero) {
                throw PythonOps.TypeError("power", y, "power must be >= 0");
            }
            if (z == BigInteger.Zero) {
                throw PythonOps.ZeroDivisionError();
            }

            BigInteger result = x.ModPow(y, z);

            // fix the sign for negative moduli or negative mantissas
            if ((z < BigInteger.Zero && result > BigInteger.Zero)
                || (z > BigInteger.Zero && result < BigInteger.Zero)) {
                result += z;
            }
            return result;
        }