Method: Float#**

Defined in:
numeric.c

#**(other) ⇒ Numeric

Raises self to the power of other:

f = 3.14
f ** 2              # => 9.8596
f ** -2             # => 0.1014239928597509
f ** 2.1            # => 11.054834900588839
f ** Rational(2, 1) # => 9.8596
f ** Complex(2, 0)  # => (9.8596+0i)

Returns:



1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
# File 'numeric.c', line 1480

VALUE
rb_float_pow(VALUE x, VALUE y)
{
    double dx, dy;
    if (y == INT2FIX(2)) {
        dx = RFLOAT_VALUE(x);
        return DBL2NUM(dx * dx);
    }
    else if (FIXNUM_P(y)) {
        dx = RFLOAT_VALUE(x);
        dy = (double)FIX2LONG(y);
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        dx = RFLOAT_VALUE(x);
        dy = rb_big2dbl(y);
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        dx = RFLOAT_VALUE(x);
        dy = RFLOAT_VALUE(y);
        if (dx < 0 && dy != round(dy))
            return rb_dbl_complex_new_polar_pi(pow(-dx, dy), dy);
    }
    else {
        return rb_num_coerce_bin(x, y, idPow);
    }
    return DBL2NUM(pow(dx, dy));
}