public double powAsDouble(double n) {
    if (this.signum == 0) {
      return 0;
    }
    double val = doubleValue();
    double result = Math.pow(val, n);
    if (Double.isInfinite(result) || Double.isNaN(result)) {
      SqlMathUtil.throwOverflowException();
    }
    return result;
  }
<p>
Calculate the power of this value in double precision. Note that this does
NOT perform the calculation in infinite accuracy. Although this sounds
weird, it's at least how SQLServer does it. The SQL below demonstrates that
SQLServer actually converts it into FLOAT (Java's double).
</p>
<code>
create table bb (col1 DECIMAL(38,36), col2 DECIMAL (38,36));
insert into bb values(1.00435134913958923485982394892384,1.00345982739817298323423423);
select power(col1, col2);
</code>
<p>
This SQL returns '1.004366436877081000000000000000000000', which is merely
a power calculated in double precision (
"java.lang.Math.pow(1.00435134913958923485982394892384d, 1.00345982739817298323423423d)"
returns 1.0043664368770813), and then scaled into DECIMAL. The same thing
happens even when "n" is a positive integer. One justification is that,
because DECIMAL is at most 38 digits, double precision is enough for
sqrt/pow.
</p>
<p>
This method does not modify this object.
</p>
<p>
This method throws exception if the calculated value is Infinite. This is
the SQL semantics (at least in SQLServer).
</p>

@param n
         power to raise this object. Unlike
         {@link java.math.BigDecimal#pow(int)}, this can receive a
         fractional number. Instead, this method calculates the value in
         double precision.
@return power of this value
common/src/java/org/apache/hadoop/hive/common/type/Decimal128.java