private Power ( double x, double y ) : double | ||
x | double | |
y | double | |
return | double |
public static object Power([NotNull] BigInteger x, long y) { if (y < 0) { return(DoubleOps.Power(x.ToFloat64(), y)); } return(x.Power(y)); }
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 float Power(float x, float y) { return((float)DoubleOps.Power(x, y)); }