private Power ( BigInteger x, BigInteger y, BigInteger z ) : object | ||
x | BigInteger | |
y | BigInteger | |
z | BigInteger | |
Résultat | object |
public static object Power(int x, int power) { if (power == 0) { return(1); } if (power < 0) { if (x == 0) { throw PythonOps.ZeroDivisionError("0.0 cannot be raised to a negative power"); } return(DoubleOps.Power(x, power)); } int factor = x; int result = 1; int savePower = power; try { checked { while (power != 0) { if ((power & 1) != 0) { result = result * factor; } if (power == 1) { break; // prevent overflow } factor = factor * factor; power >>= 1; } return(result); } } catch (OverflowException) { return(BigIntegerOps.Power((BigInteger)x, savePower)); } }
public static object Power(int x, BigInteger power, BigInteger qmod) { return(BigIntegerOps.Power((BigInteger)x, power, qmod)); }