power(p1)
public
Returns the value raised to the power
of n. Note that n must be an Integer.
Also available as the operator **
static VALUE
BigDecimal_power(VALUE self, VALUE p)
{
ENTER(5);
Real *x, *y;
S_LONG mp, ma, n;
Check_Type(p, T_FIXNUM);
n = FIX2INT(p);
ma = n;
if(ma < 0) ma = -ma;
if(ma == 0) ma = 1;
GUARD_OBJ(x,GetVpValue(self,1));
if(VpIsDef(x)) {
mp = x->Prec *(VpBaseFig() + 1);
GUARD_OBJ(y,VpCreateRbObject(mp *(ma + 1), "0"));
} else {
GUARD_OBJ(y,VpCreateRbObject(1, "0"));
}
VpPower(y, x, n);
return ToValue(y);
}