Esempio n. 1
0
Decimal & Decimal::power(int value)
{
    if ( value >= 0)
        return power((unsigned)value);

#if 1
    //This probably gives slightly more expected results, but both suffer from rounding errors.
    Decimal reciprocal;
    reciprocal.setInt(1);
    reciprocal.divide(*this);
    set(reciprocal);
    doPower((unsigned)-value);
    return *this;
#else
    doPower((unsigned)-value);
    Decimal reciprocal;
    reciprocal.setInt(1);
    reciprocal.divide(*this);
    set(reciprocal);
    return *this;
#endif
}