Skip to content

Commit 7bd6754

Browse files
committed
Add overload with BigDecimal
1 parent c6296c0 commit 7bd6754

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

stdlib/bigdecimal/0/big_decimal.rbs

+61
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,23 @@ class Integer
15001500
#
15011501
def -: (BigDecimal) -> BigDecimal
15021502
| ...
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+
| ...
15031520
end
15041521

15051522
%a{annotate:rdoc:skip}
@@ -1584,6 +1601,22 @@ class Float
15841601
#
15851602
def -: (BigDecimal) -> BigDecimal
15861603
| ...
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+
| ...
15871620
end
15881621

15891622
%a{annotate:rdoc:skip}
@@ -1687,6 +1720,22 @@ class Rational
16871720
#
16881721
def -: (BigDecimal) -> BigDecimal
16891722
| ...
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+
| ...
16901739
end
16911740

16921741
%a{annotate:rdoc:skip}
@@ -1771,6 +1820,18 @@ class Complex
17711820
#
17721821
def -: (BigDecimal) -> Complex
17731822
| ...
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+
| ...
17741835
end
17751836

17761837
%a{annotate:rdoc:skip}

0 commit comments

Comments
 (0)