/* calculate the expoonent */
Integer bi;
Unit thisUnit;
Complex thisComplex;
if (bIsReal && bMagIsInteger){
/* If this.cComplex.getImaginary==0 then it must remain zero, since
exponent is whole nmber. Otherwise, we get small neg imaginary value
which results in sqrt((-2)^2)=-2 which is technically correct but
unexpected. */
boolean zeroimag = false;
if (this.cComplex.getImaginary()==0){
zeroimag = true;
}
bi = (Integer)bo;
thisUnit = this.getUnit().pow(bi);
thisComplex = this.cComplex.pow(bi.doubleValue());
//thisComplex = Complex.valueOf(Math.pow(this.cComplex.getReal(),bi),0);
if (zeroimag){
thisComplex = Complex.valueOf(thisComplex.getReal(),0);
}
return ComplexAmount.valueOf(thisComplex, thisUnit);
}
else if (bIsReal && bInvIsInteger){
/* If the inverse is an integer then we can take a root */
thisUnit = this.getUnit().root(bInv);
thisComplex = this.cComplex.pow(1/bInv.doubleValue());
return ComplexAmount.valueOf(thisComplex,thisUnit);
}
else if (aIsUnitless){
Logger.getLogger("com.CompPad").log(Level.FINE, bo + " " + this.cComplex);
/* Must be complex or double */
Complex a;
Complex bb;
a = this.cComplex;
bb = b.cComplex;
return ComplexAmount.valueOf(
a.pow(bb),
Unit.ONE);