@@ -1500,6 +1500,23 @@ class Integer
1500
1500
#
1501
1501
def - : (BigDecimal) -> BigDecimal
1502
1502
| ...
1503
+
1504
+ # <!--
1505
+ # rdoc-file=numeric.c
1506
+ # - self ** numeric -> numeric_result
1507
+ # -->
1508
+ # Raises `self` to the power of `numeric`:
1509
+ #
1510
+ # 2 ** 3 # => 8
1511
+ # 2 ** -3 # => (1/8)
1512
+ # -2 ** 3 # => -8
1513
+ # -2 ** -3 # => (-1/8)
1514
+ # 2 ** 3.3 # => 9.849155306759329
1515
+ # 2 ** Rational(3, 1) # => (8/1)
1516
+ # 2 ** Complex(3, 0) # => (8+0i)
1517
+ #
1518
+ def ** : (BigDecimal) -> BigDecimal
1519
+ | ...
1503
1520
end
1504
1521
1505
1522
%a{annotate:rdoc:skip}
@@ -1584,6 +1601,22 @@ class Float
1584
1601
#
1585
1602
def - : (BigDecimal) -> BigDecimal
1586
1603
| ...
1604
+
1605
+ # <!--
1606
+ # rdoc-file=numeric.c
1607
+ # - self ** other -> numeric
1608
+ # -->
1609
+ # Raises `self` to the power of `other`:
1610
+ #
1611
+ # f = 3.14
1612
+ # f ** 2 # => 9.8596
1613
+ # f ** -2 # => 0.1014239928597509
1614
+ # f ** 2.1 # => 11.054834900588839
1615
+ # f ** Rational(2, 1) # => 9.8596
1616
+ # f ** Complex(2, 0) # => (9.8596+0i)
1617
+ #
1618
+ def ** : (BigDecimal) -> BigDecimal
1619
+ | ...
1587
1620
end
1588
1621
1589
1622
%a{annotate:rdoc:skip}
@@ -1687,6 +1720,22 @@ class Rational
1687
1720
#
1688
1721
def - : (BigDecimal) -> BigDecimal
1689
1722
| ...
1723
+
1724
+ # <!--
1725
+ # rdoc-file=rational.c
1726
+ # - rat ** numeric -> numeric
1727
+ # -->
1728
+ # Performs exponentiation.
1729
+ #
1730
+ # Rational(2) ** Rational(3) #=> (8/1)
1731
+ # Rational(10) ** -2 #=> (1/100)
1732
+ # Rational(10) ** -2.0 #=> 0.01
1733
+ # Rational(-4) ** Rational(1, 2) #=> (0.0+2.0i)
1734
+ # Rational(1, 2) ** 0 #=> (1/1)
1735
+ # Rational(1, 2) ** 0.0 #=> 1.0
1736
+ #
1737
+ def ** : (BigDecimal) -> (Rational | BigDecimal)
1738
+ | ...
1690
1739
end
1691
1740
1692
1741
%a{annotate:rdoc:skip}
@@ -1771,6 +1820,18 @@ class Complex
1771
1820
#
1772
1821
def - : (BigDecimal) -> Complex
1773
1822
| ...
1823
+
1824
+ # <!--
1825
+ # rdoc-file=complex.c
1826
+ # - complex ** numeric -> new_complex
1827
+ # -->
1828
+ # Returns `self` raised to power `numeric`:
1829
+ #
1830
+ # Complex('i') ** 2 # => (-1+0i)
1831
+ # Complex(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
1832
+ #
1833
+ def ** : (BigDecimal) -> Complex
1834
+ | ...
1774
1835
end
1775
1836
1776
1837
%a{annotate:rdoc:skip}
0 commit comments