%mathpiper,def="MathIntPower"

// power x^y only for integer y (perhaps negative)
Defun("MathIntPower", {x,y})
	If(IsEqual(x,0),0,If(IsEqual(x,1),1,
	 If(IsInteger(y),If(IsLessThan(y,0), // negative power, need to convert x to float to save time, since x^(-n) is never going to be integer anyway
	  DivideN(1, PositiveIntPower(AddN(x,0.),MathNegate(y))),
	   // now the positive integer y calculation - note that x might still be integer
	  PositiveIntPower(x,y)
	 ),	// floating-point calculation is absent, return False
	 False)
	));

%/mathpiper