Skip to content

Commit dfcfaf2

Browse files
committed
Add missing methods for BigMath
1 parent 92c61d1 commit dfcfaf2

File tree

1 file changed

+51
-10
lines changed

1 file changed

+51
-10
lines changed

gems/bigdecimal/4.0/bigdecimal-math.rbs

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,20 @@ module BigMath
139139
#
140140
def self?.cosh: (BigDecimal, Numeric) -> BigDecimal
141141

142-
# Computes the error function of +decimal+ to the specified number of digits of
143-
# precision, +numeric+.
142+
# Computes the error function of `decimal` to the specified number of digits of
143+
# precision, `numeric`.
144144
#
145-
# If +decimal+ is NaN, returns NaN.
145+
# If `decimal` is NaN, returns NaN.
146146
#
147147
# BigMath.erf(BigDecimal('1'), 32).to_s
148148
# #=> "0.84270079294971486934122063508261e0"
149149
#
150150
def self?.erf: (BigDecimal, Numeric) -> BigDecimal
151151

152-
# Computes the complementary error function of +decimal+ to the specified number of digits of
153-
# precision, +numeric+.
152+
# Computes the complementary error function of `decimal` to the specified number of digits of
153+
# precision, `numeric`.
154154
#
155-
# If +decimal+ is NaN, returns NaN.
155+
# If `decimal` is NaN, returns NaN.
156156
#
157157
# BigMath.erfc(BigDecimal('10'), 32).to_s
158158
# #=> "0.20884875837625447570007862949578e-44"
@@ -168,15 +168,22 @@ module BigMath
168168
#
169169
def self?.exp: (BigDecimal, Numeric prec) -> BigDecimal
170170

171+
# Computes exp(decimal) - 1 to the specified number of digits of precision, `numeric`.
172+
#
173+
# BigMath.expm1(BigDecimal('0.1'), 32).to_s
174+
# #=> "0.10517091807564762481170782649025e0"
175+
#
176+
def self?.expm1: (BigDecimal, Numeric prec) -> BigDecimal
177+
171178
# Decomposes +x+ into a normalized fraction and an integral power of ten.
172179
#
173180
# BigMath.frexp(BigDecimal(123.456))
174181
# #=> [0.123456e0, 3]
175182
#
176183
def self?.frexp: (BigDecimal) -> [ BigDecimal, Integer ]
177184

178-
# Computes the gamma function of +decimal+ to the specified number of
179-
# digits of precision, +numeric+.
185+
# Computes the gamma function of `decimal` to the specified number of
186+
# digits of precision, `numeric`.
180187
#
181188
# BigMath.gamma(BigDecimal('0.5'), 32).to_s
182189
# #=> "0.17724538509055160272981674833411e1"
@@ -200,12 +207,12 @@ module BigMath
200207
def self?.ldexp: (BigDecimal, Integer) -> BigDecimal
201208

202209
# Computes the natural logarithm of the absolute value of the gamma function
203-
# of +decimal+ to the specified number of digits of precision, +numeric+ and its sign.
210+
# of `decimal` to the specified number of digits of precision, `numeric` and its sign.
204211
#
205212
# BigMath.lgamma(BigDecimal('0.5'), 32)
206213
# #=> [0.57236494292470008707171367567653e0, 1]
207214
#
208-
def self?.lgamma: (BigDecimal, Numeric) -> [BigDecimal, Integer]
215+
def self?.lgamma: (BigDecimal, Numeric) -> [ BigDecimal, Integer ]
209216

210217
# Computes the natural logarithm of `decimal` to the specified number of digits
211218
# of precision, `numeric`.
@@ -218,6 +225,27 @@ module BigMath
218225
#
219226
def self?.log: (BigDecimal, Numeric prec) -> BigDecimal
220227

228+
# Computes the base 10 logarithm of `decimal` to the specified number of
229+
# digits of precision, `numeric`.
230+
#
231+
# If `decimal` is zero or negative, raises Math::DomainError.
232+
#
233+
# If `decimal` is positive infinity, returns Infinity.
234+
#
235+
# If `decimal` is NaN, returns NaN.
236+
#
237+
# BigMath.log10(BigDecimal('3'), 32).to_s
238+
# #=> "0.47712125471966243729502790325512e0"
239+
#
240+
def self?.log10: (BigDecimal, Numeric prec) -> BigDecimal
241+
242+
# Computes log(1 + decimal) to the specified number of digits of precision, `numeric`.
243+
#
244+
# BigMath.log1p(BigDecimal('0.1'), 32).to_s
245+
# #=> "0.95310179804324860043952123280765e-1"
246+
#
247+
def self?.log1p: (BigDecimal, Numeric prec) -> BigDecimal
248+
221249
# Computes the base 2 logarithm of `decimal` to the specified number of digits
222250
# of precision, `numeric`.
223251
#
@@ -268,6 +296,19 @@ module BigMath
268296
#
269297
def self?.sqrt: (BigDecimal x, Numeric prec) -> BigDecimal
270298

299+
# Computes the tangent of `decimal` to the specified number of digits of
300+
# precision, `numeric`.
301+
#
302+
# If `decimal` is Infinity or NaN, returns NaN.
303+
#
304+
# BigMath.tan(BigDecimal("0.0"), 4).to_s
305+
# #=> "0.0"
306+
#
307+
# BigMath.tan(BigMath.PI(24) / 4, 32).to_s
308+
# #=> "0.99999999999999999999999830836025e0"
309+
#
310+
def self?.tan: (BigDecimal x, Numeric prec) -> BigDecimal
311+
271312
# Computes the hyperbolic tangent of `decimal` to the specified number of digits
272313
# of precision, `numeric`.
273314
#

0 commit comments

Comments
 (0)