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;
}