bigdecimal 4.0.1-java → 4.1.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bigdecimal.gemspec +6 -1
- data/lib/bigdecimal/math.rb +101 -122
- data/lib/bigdecimal/util.rb +1 -1
- data/lib/bigdecimal.rb +86 -59
- data/sample/linear.rb +73 -37
- data/sample/nlsolve.rb +47 -30
- data/sample/pi.rb +2 -7
- data/sig/big_decimal.rbs +1502 -0
- data/sig/big_decimal_util.rbs +158 -0
- data/sig/big_math.rbs +423 -0
- metadata +5 -2
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
%a{annotate:rdoc:skip}
|
|
2
|
+
class Integer
|
|
3
|
+
# <!--
|
|
4
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
5
|
+
# - int.to_d -> bigdecimal
|
|
6
|
+
# -->
|
|
7
|
+
# Returns the value of `int` as a BigDecimal.
|
|
8
|
+
#
|
|
9
|
+
# require 'bigdecimal'
|
|
10
|
+
# require 'bigdecimal/util'
|
|
11
|
+
#
|
|
12
|
+
# 42.to_d # => 0.42e2
|
|
13
|
+
#
|
|
14
|
+
# See also Kernel.BigDecimal.
|
|
15
|
+
#
|
|
16
|
+
def to_d: () -> BigDecimal
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
%a{annotate:rdoc:skip}
|
|
20
|
+
class Float
|
|
21
|
+
# <!--
|
|
22
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
23
|
+
# - float.to_d -> bigdecimal
|
|
24
|
+
# - float.to_d(precision) -> bigdecimal
|
|
25
|
+
# -->
|
|
26
|
+
# Returns the value of `float` as a BigDecimal. The `precision` parameter is
|
|
27
|
+
# used to determine the number of significant digits for the result. When
|
|
28
|
+
# `precision` is set to `0`, the number of digits to represent the float being
|
|
29
|
+
# converted is determined automatically. The default `precision` is `0`.
|
|
30
|
+
#
|
|
31
|
+
# require 'bigdecimal'
|
|
32
|
+
# require 'bigdecimal/util'
|
|
33
|
+
#
|
|
34
|
+
# 0.5.to_d # => 0.5e0
|
|
35
|
+
# 1.234.to_d # => 0.1234e1
|
|
36
|
+
# 1.234.to_d(2) # => 0.12e1
|
|
37
|
+
#
|
|
38
|
+
# See also Kernel.BigDecimal.
|
|
39
|
+
#
|
|
40
|
+
def to_d: (?Integer precision) -> BigDecimal
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
%a{annotate:rdoc:skip}
|
|
44
|
+
class String
|
|
45
|
+
# <!--
|
|
46
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
47
|
+
# - str.to_d -> bigdecimal
|
|
48
|
+
# -->
|
|
49
|
+
# Returns the result of interpreting leading characters in `str` as a
|
|
50
|
+
# BigDecimal.
|
|
51
|
+
#
|
|
52
|
+
# require 'bigdecimal'
|
|
53
|
+
# require 'bigdecimal/util'
|
|
54
|
+
#
|
|
55
|
+
# "0.5".to_d # => 0.5e0
|
|
56
|
+
# "123.45e1".to_d # => 0.12345e4
|
|
57
|
+
# "45.67 degrees".to_d # => 0.4567e2
|
|
58
|
+
#
|
|
59
|
+
# See also Kernel.BigDecimal.
|
|
60
|
+
#
|
|
61
|
+
def to_d: () -> BigDecimal
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
%a{annotate:rdoc:skip}
|
|
65
|
+
class BigDecimal
|
|
66
|
+
# <!--
|
|
67
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
68
|
+
# - a.to_digits -> string
|
|
69
|
+
# -->
|
|
70
|
+
# Converts a BigDecimal to a String of the form "nnnnnn.mmm". This method is
|
|
71
|
+
# deprecated; use BigDecimal#to_s("F") instead.
|
|
72
|
+
#
|
|
73
|
+
# require 'bigdecimal/util'
|
|
74
|
+
#
|
|
75
|
+
# d = BigDecimal("3.14")
|
|
76
|
+
# d.to_digits # => "3.14"
|
|
77
|
+
#
|
|
78
|
+
def to_digits: () -> String
|
|
79
|
+
|
|
80
|
+
# <!--
|
|
81
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
82
|
+
# - a.to_d -> bigdecimal
|
|
83
|
+
# -->
|
|
84
|
+
# Returns self.
|
|
85
|
+
#
|
|
86
|
+
# require 'bigdecimal/util'
|
|
87
|
+
#
|
|
88
|
+
# d = BigDecimal("3.14")
|
|
89
|
+
# d.to_d # => 0.314e1
|
|
90
|
+
#
|
|
91
|
+
def to_d: () -> BigDecimal
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
%a{annotate:rdoc:skip}
|
|
95
|
+
class Rational
|
|
96
|
+
# <!--
|
|
97
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
98
|
+
# - rat.to_d(precision) -> bigdecimal
|
|
99
|
+
# -->
|
|
100
|
+
# Returns the value as a BigDecimal.
|
|
101
|
+
#
|
|
102
|
+
# The `precision` parameter is used to determine the number of significant
|
|
103
|
+
# digits for the result. When `precision` is set to `0`, the number of digits to
|
|
104
|
+
# represent the float being converted is determined automatically. The default
|
|
105
|
+
# `precision` is `0`.
|
|
106
|
+
#
|
|
107
|
+
# require 'bigdecimal'
|
|
108
|
+
# require 'bigdecimal/util'
|
|
109
|
+
#
|
|
110
|
+
# Rational(22, 7).to_d(3) # => 0.314e1
|
|
111
|
+
#
|
|
112
|
+
# See also Kernel.BigDecimal.
|
|
113
|
+
#
|
|
114
|
+
def to_d: (Integer precision) -> BigDecimal
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
%a{annotate:rdoc:skip}
|
|
118
|
+
class Complex
|
|
119
|
+
# <!--
|
|
120
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
121
|
+
# - cmp.to_d -> bigdecimal
|
|
122
|
+
# - cmp.to_d(precision) -> bigdecimal
|
|
123
|
+
# -->
|
|
124
|
+
# Returns the value as a BigDecimal. If the imaginary part is not `0`, an error
|
|
125
|
+
# is raised
|
|
126
|
+
#
|
|
127
|
+
# The `precision` parameter is used to determine the number of significant
|
|
128
|
+
# digits for the result. When `precision` is set to `0`, the number of digits to
|
|
129
|
+
# represent the float being converted is determined automatically. The default
|
|
130
|
+
# `precision` is `0`.
|
|
131
|
+
#
|
|
132
|
+
# require 'bigdecimal'
|
|
133
|
+
# require 'bigdecimal/util'
|
|
134
|
+
#
|
|
135
|
+
# Complex(0.1234567, 0).to_d(4) # => 0.1235e0
|
|
136
|
+
# Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
|
|
137
|
+
# Complex(1, 1).to_d # raises ArgumentError
|
|
138
|
+
#
|
|
139
|
+
# See also Kernel.BigDecimal.
|
|
140
|
+
#
|
|
141
|
+
def to_d: (*untyped args) -> BigDecimal
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
%a{annotate:rdoc:skip}
|
|
145
|
+
class NilClass
|
|
146
|
+
# <!--
|
|
147
|
+
# rdoc-file=lib/bigdecimal/util.rb
|
|
148
|
+
# - nil.to_d -> bigdecimal
|
|
149
|
+
# -->
|
|
150
|
+
# Returns nil represented as a BigDecimal.
|
|
151
|
+
#
|
|
152
|
+
# require 'bigdecimal'
|
|
153
|
+
# require 'bigdecimal/util'
|
|
154
|
+
#
|
|
155
|
+
# nil.to_d # => 0.0
|
|
156
|
+
#
|
|
157
|
+
def to_d: () -> BigDecimal
|
|
158
|
+
end
|
data/sig/big_math.rbs
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# <!-- rdoc-file=lib/bigdecimal.rb -->
|
|
2
|
+
# Core BigMath methods for BigDecimal (log, exp) are defined here. Other methods
|
|
3
|
+
# (sin, cos, atan) are defined in 'bigdecimal/math.rb'.
|
|
4
|
+
#
|
|
5
|
+
# <!-- rdoc-file=lib/bigdecimal/math.rb -->
|
|
6
|
+
# Provides mathematical functions.
|
|
7
|
+
#
|
|
8
|
+
# Example:
|
|
9
|
+
#
|
|
10
|
+
# require "bigdecimal/math"
|
|
11
|
+
#
|
|
12
|
+
# include BigMath
|
|
13
|
+
#
|
|
14
|
+
# a = BigDecimal((PI(49)/2).to_s)
|
|
15
|
+
# puts sin(a,100) # => 0.9999999999...9999999986e0
|
|
16
|
+
#
|
|
17
|
+
module BigMath
|
|
18
|
+
# <!--
|
|
19
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
20
|
+
# - E(numeric) -> BigDecimal
|
|
21
|
+
# -->
|
|
22
|
+
# Computes e (the base of natural logarithms) to the specified number of digits
|
|
23
|
+
# of precision, `numeric`.
|
|
24
|
+
#
|
|
25
|
+
# BigMath.E(32).to_s
|
|
26
|
+
# #=> "0.27182818284590452353602874713527e1"
|
|
27
|
+
#
|
|
28
|
+
def self?.E: (int prec) -> BigDecimal
|
|
29
|
+
|
|
30
|
+
# <!--
|
|
31
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
32
|
+
# - PI(numeric) -> BigDecimal
|
|
33
|
+
# -->
|
|
34
|
+
# Computes the value of pi to the specified number of digits of precision,
|
|
35
|
+
# `numeric`.
|
|
36
|
+
#
|
|
37
|
+
# BigMath.PI(32).to_s
|
|
38
|
+
# #=> "0.31415926535897932384626433832795e1"
|
|
39
|
+
#
|
|
40
|
+
def self?.PI: (int prec) -> BigDecimal
|
|
41
|
+
|
|
42
|
+
# <!--
|
|
43
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
44
|
+
# - acos(decimal, numeric) -> BigDecimal
|
|
45
|
+
# -->
|
|
46
|
+
# Computes the arccosine of `decimal` to the specified number of digits of
|
|
47
|
+
# precision, `numeric`.
|
|
48
|
+
#
|
|
49
|
+
# If `decimal` is NaN, returns NaN.
|
|
50
|
+
#
|
|
51
|
+
# BigMath.acos(BigDecimal('0.5'), 32).to_s
|
|
52
|
+
# #=> "0.10471975511965977461542144610932e1"
|
|
53
|
+
#
|
|
54
|
+
def self?.acos: (real | BigDecimal, int prec) -> BigDecimal
|
|
55
|
+
|
|
56
|
+
# <!--
|
|
57
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
58
|
+
# - acosh(decimal, numeric) -> BigDecimal
|
|
59
|
+
# -->
|
|
60
|
+
# Computes the inverse hyperbolic cosine of `decimal` to the specified number of
|
|
61
|
+
# digits of precision, `numeric`.
|
|
62
|
+
#
|
|
63
|
+
# If `decimal` is NaN, returns NaN.
|
|
64
|
+
#
|
|
65
|
+
# BigMath.acosh(BigDecimal('2'), 32).to_s
|
|
66
|
+
# #=> "0.1316957896924816708625046347308e1"
|
|
67
|
+
#
|
|
68
|
+
def self?.acosh: (real | BigDecimal, int prec) -> BigDecimal
|
|
69
|
+
|
|
70
|
+
# <!--
|
|
71
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
72
|
+
# - asin(decimal, numeric) -> BigDecimal
|
|
73
|
+
# -->
|
|
74
|
+
# Computes the arcsine of `decimal` to the specified number of digits of
|
|
75
|
+
# precision, `numeric`.
|
|
76
|
+
#
|
|
77
|
+
# If `decimal` is NaN, returns NaN.
|
|
78
|
+
#
|
|
79
|
+
# BigMath.asin(BigDecimal('0.5'), 32).to_s
|
|
80
|
+
# #=> "0.52359877559829887307710723054658e0"
|
|
81
|
+
#
|
|
82
|
+
def self?.asin: (real | BigDecimal, int prec) -> BigDecimal
|
|
83
|
+
|
|
84
|
+
# <!--
|
|
85
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
86
|
+
# - asinh(decimal, numeric) -> BigDecimal
|
|
87
|
+
# -->
|
|
88
|
+
# Computes the inverse hyperbolic sine of `decimal` to the specified number of
|
|
89
|
+
# digits of precision, `numeric`.
|
|
90
|
+
#
|
|
91
|
+
# If `decimal` is NaN, returns NaN.
|
|
92
|
+
#
|
|
93
|
+
# BigMath.asinh(BigDecimal('1'), 32).to_s
|
|
94
|
+
# #=> "0.88137358701954302523260932497979e0"
|
|
95
|
+
#
|
|
96
|
+
def self?.asinh: (real | BigDecimal, int prec) -> BigDecimal
|
|
97
|
+
|
|
98
|
+
# <!--
|
|
99
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
100
|
+
# - atan(decimal, numeric) -> BigDecimal
|
|
101
|
+
# -->
|
|
102
|
+
# Computes the arctangent of `decimal` to the specified number of digits of
|
|
103
|
+
# precision, `numeric`.
|
|
104
|
+
#
|
|
105
|
+
# If `decimal` is NaN, returns NaN.
|
|
106
|
+
#
|
|
107
|
+
# BigMath.atan(BigDecimal('-1'), 32).to_s
|
|
108
|
+
# #=> "-0.78539816339744830961566084581988e0"
|
|
109
|
+
#
|
|
110
|
+
def self?.atan: (real | BigDecimal x, int prec) -> BigDecimal
|
|
111
|
+
|
|
112
|
+
# <!--
|
|
113
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
114
|
+
# - atan2(decimal, decimal, numeric) -> BigDecimal
|
|
115
|
+
# -->
|
|
116
|
+
# Computes the arctangent of y and x to the specified number of digits of
|
|
117
|
+
# precision, `numeric`.
|
|
118
|
+
#
|
|
119
|
+
# BigMath.atan2(BigDecimal('-1'), BigDecimal('1'), 32).to_s
|
|
120
|
+
# #=> "-0.78539816339744830961566084581988e0"
|
|
121
|
+
#
|
|
122
|
+
def self?.atan2: (real | BigDecimal, real | BigDecimal, int prec) -> BigDecimal
|
|
123
|
+
|
|
124
|
+
# <!--
|
|
125
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
126
|
+
# - atanh(decimal, numeric) -> BigDecimal
|
|
127
|
+
# -->
|
|
128
|
+
# Computes the inverse hyperbolic tangent of `decimal` to the specified number
|
|
129
|
+
# of digits of precision, `numeric`.
|
|
130
|
+
#
|
|
131
|
+
# If `decimal` is NaN, returns NaN.
|
|
132
|
+
#
|
|
133
|
+
# BigMath.atanh(BigDecimal('0.5'), 32).to_s
|
|
134
|
+
# #=> "0.54930614433405484569762261846126e0"
|
|
135
|
+
#
|
|
136
|
+
def self?.atanh: (real | BigDecimal, int prec) -> BigDecimal
|
|
137
|
+
|
|
138
|
+
# <!--
|
|
139
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
140
|
+
# - cbrt(decimal, numeric) -> BigDecimal
|
|
141
|
+
# -->
|
|
142
|
+
# Computes the cube root of `decimal` to the specified number of digits of
|
|
143
|
+
# precision, `numeric`.
|
|
144
|
+
#
|
|
145
|
+
# BigMath.cbrt(BigDecimal('2'), 32).to_s
|
|
146
|
+
# #=> "0.12599210498948731647672106072782e1"
|
|
147
|
+
#
|
|
148
|
+
def self?.cbrt: (real | BigDecimal, int prec) -> BigDecimal
|
|
149
|
+
|
|
150
|
+
# <!--
|
|
151
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
152
|
+
# - cos(decimal, numeric) -> BigDecimal
|
|
153
|
+
# -->
|
|
154
|
+
# Computes the cosine of `decimal` to the specified number of digits of
|
|
155
|
+
# precision, `numeric`.
|
|
156
|
+
#
|
|
157
|
+
# If `decimal` is Infinity or NaN, returns NaN.
|
|
158
|
+
#
|
|
159
|
+
# BigMath.cos(BigMath.PI(16), 32).to_s
|
|
160
|
+
# #=> "-0.99999999999999999999999999999997e0"
|
|
161
|
+
#
|
|
162
|
+
def self?.cos: (real | BigDecimal x, int prec) -> BigDecimal
|
|
163
|
+
|
|
164
|
+
# <!--
|
|
165
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
166
|
+
# - cosh(decimal, numeric) -> BigDecimal
|
|
167
|
+
# -->
|
|
168
|
+
# Computes the hyperbolic cosine of `decimal` to the specified number of digits
|
|
169
|
+
# of precision, `numeric`.
|
|
170
|
+
#
|
|
171
|
+
# If `decimal` is NaN, returns NaN.
|
|
172
|
+
#
|
|
173
|
+
# BigMath.cosh(BigDecimal('1'), 32).to_s
|
|
174
|
+
# #=> "0.15430806348152437784779056207571e1"
|
|
175
|
+
#
|
|
176
|
+
def self?.cosh: (real | BigDecimal, int prec) -> BigDecimal
|
|
177
|
+
|
|
178
|
+
# <!--
|
|
179
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
180
|
+
# - erf(decimal, numeric) -> BigDecimal
|
|
181
|
+
# -->
|
|
182
|
+
# Computes the error function of `decimal` to the specified number of digits of
|
|
183
|
+
# precision, `numeric`.
|
|
184
|
+
#
|
|
185
|
+
# If `decimal` is NaN, returns NaN.
|
|
186
|
+
#
|
|
187
|
+
# BigMath.erf(BigDecimal('1'), 32).to_s
|
|
188
|
+
# #=> "0.84270079294971486934122063508261e0"
|
|
189
|
+
#
|
|
190
|
+
def self?.erf: (real | BigDecimal, int prec) -> BigDecimal
|
|
191
|
+
|
|
192
|
+
# <!--
|
|
193
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
194
|
+
# - erfc(decimal, numeric) -> BigDecimal
|
|
195
|
+
# -->
|
|
196
|
+
# Computes the complementary error function of `decimal` to the specified number
|
|
197
|
+
# of digits of precision, `numeric`.
|
|
198
|
+
#
|
|
199
|
+
# If `decimal` is NaN, returns NaN.
|
|
200
|
+
#
|
|
201
|
+
# BigMath.erfc(BigDecimal('10'), 32).to_s
|
|
202
|
+
# #=> "0.20884875837625447570007862949578e-44"
|
|
203
|
+
#
|
|
204
|
+
def self?.erfc: (real | BigDecimal, int prec) -> BigDecimal
|
|
205
|
+
|
|
206
|
+
# <!--
|
|
207
|
+
# rdoc-file=lib/bigdecimal.rb
|
|
208
|
+
# - BigMath.exp(decimal, numeric) -> BigDecimal
|
|
209
|
+
# -->
|
|
210
|
+
# Computes the value of e (the base of natural logarithms) raised to the power
|
|
211
|
+
# of `decimal`, to the specified number of digits of precision.
|
|
212
|
+
#
|
|
213
|
+
# If `decimal` is infinity, returns Infinity.
|
|
214
|
+
#
|
|
215
|
+
# If `decimal` is NaN, returns NaN.
|
|
216
|
+
#
|
|
217
|
+
def self?.exp: (real | BigDecimal, int prec) -> BigDecimal
|
|
218
|
+
|
|
219
|
+
# <!--
|
|
220
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
221
|
+
# - BigMath.expm1(decimal, numeric) -> BigDecimal
|
|
222
|
+
# -->
|
|
223
|
+
# Computes exp(decimal) - 1 to the specified number of digits of precision,
|
|
224
|
+
# `numeric`.
|
|
225
|
+
#
|
|
226
|
+
# BigMath.expm1(BigDecimal('0.1'), 32).to_s
|
|
227
|
+
# #=> "0.10517091807564762481170782649025e0"
|
|
228
|
+
#
|
|
229
|
+
def self?.expm1: (real | BigDecimal, int prec) -> BigDecimal
|
|
230
|
+
|
|
231
|
+
# <!--
|
|
232
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
233
|
+
# - frexp(x) -> [BigDecimal, Integer]
|
|
234
|
+
# -->
|
|
235
|
+
# Decomposes `x` into a normalized fraction and an integral power of ten.
|
|
236
|
+
#
|
|
237
|
+
# BigMath.frexp(BigDecimal(123.456))
|
|
238
|
+
# #=> [0.123456e0, 3]
|
|
239
|
+
#
|
|
240
|
+
def self?.frexp: (real | BigDecimal x) -> [ BigDecimal, Integer ]
|
|
241
|
+
|
|
242
|
+
# <!--
|
|
243
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
244
|
+
# - BigMath.gamma(decimal, numeric) -> BigDecimal
|
|
245
|
+
# -->
|
|
246
|
+
# Computes the gamma function of `decimal` to the specified number of digits of
|
|
247
|
+
# precision, `numeric`.
|
|
248
|
+
#
|
|
249
|
+
# BigMath.gamma(BigDecimal('0.5'), 32).to_s
|
|
250
|
+
# #=> "0.17724538509055160272981674833411e1"
|
|
251
|
+
#
|
|
252
|
+
def self?.gamma: (real | BigDecimal, int prec) -> BigDecimal
|
|
253
|
+
|
|
254
|
+
# <!--
|
|
255
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
256
|
+
# - hypot(x, y, numeric) -> BigDecimal
|
|
257
|
+
# -->
|
|
258
|
+
# Returns sqrt(x**2 + y**2) to the specified number of digits of precision,
|
|
259
|
+
# `numeric`.
|
|
260
|
+
#
|
|
261
|
+
# BigMath.hypot(BigDecimal('1'), BigDecimal('2'), 32).to_s
|
|
262
|
+
# #=> "0.22360679774997896964091736687313e1"
|
|
263
|
+
#
|
|
264
|
+
def self?.hypot: (real | BigDecimal, real | BigDecimal, int prec) -> BigDecimal
|
|
265
|
+
|
|
266
|
+
# <!--
|
|
267
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
268
|
+
# - ldexp(fraction, exponent) -> BigDecimal
|
|
269
|
+
# -->
|
|
270
|
+
# Inverse of `frexp`. Returns the value of fraction * 10**exponent.
|
|
271
|
+
#
|
|
272
|
+
# BigMath.ldexp(BigDecimal("0.123456e0"), 3)
|
|
273
|
+
# #=> 0.123456e3
|
|
274
|
+
#
|
|
275
|
+
def self?.ldexp: (real | BigDecimal fraction, Integer exponent) -> BigDecimal
|
|
276
|
+
|
|
277
|
+
# <!--
|
|
278
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
279
|
+
# - BigMath.lgamma(decimal, numeric) -> [BigDecimal, Integer]
|
|
280
|
+
# -->
|
|
281
|
+
# Computes the natural logarithm of the absolute value of the gamma function of
|
|
282
|
+
# `decimal` to the specified number of digits of precision, `numeric` and its
|
|
283
|
+
# sign.
|
|
284
|
+
#
|
|
285
|
+
# BigMath.lgamma(BigDecimal('0.5'), 32)
|
|
286
|
+
# #=> [0.57236494292470008707171367567653e0, 1]
|
|
287
|
+
#
|
|
288
|
+
def self?.lgamma: (real | BigDecimal, int prec) -> [ BigDecimal, Integer ]
|
|
289
|
+
|
|
290
|
+
# <!--
|
|
291
|
+
# rdoc-file=lib/bigdecimal.rb
|
|
292
|
+
# - BigMath.log(decimal, numeric) -> BigDecimal
|
|
293
|
+
# -->
|
|
294
|
+
# Computes the natural logarithm of `decimal` to the specified number of digits
|
|
295
|
+
# of precision, `numeric`.
|
|
296
|
+
#
|
|
297
|
+
# If `decimal` is zero or negative, raises Math::DomainError.
|
|
298
|
+
#
|
|
299
|
+
# If `decimal` is positive infinity, returns Infinity.
|
|
300
|
+
#
|
|
301
|
+
# If `decimal` is NaN, returns NaN.
|
|
302
|
+
#
|
|
303
|
+
def self?.log: (real | BigDecimal, int prec) -> BigDecimal
|
|
304
|
+
|
|
305
|
+
# <!--
|
|
306
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
307
|
+
# - BigMath.log10(decimal, numeric) -> BigDecimal
|
|
308
|
+
# -->
|
|
309
|
+
# Computes the base 10 logarithm of `decimal` to the specified number of digits
|
|
310
|
+
# of precision, `numeric`.
|
|
311
|
+
#
|
|
312
|
+
# If `decimal` is zero or negative, raises Math::DomainError.
|
|
313
|
+
#
|
|
314
|
+
# If `decimal` is positive infinity, returns Infinity.
|
|
315
|
+
#
|
|
316
|
+
# If `decimal` is NaN, returns NaN.
|
|
317
|
+
#
|
|
318
|
+
# BigMath.log10(BigDecimal('3'), 32).to_s
|
|
319
|
+
# #=> "0.47712125471966243729502790325512e0"
|
|
320
|
+
#
|
|
321
|
+
def self?.log10: (real | BigDecimal, int prec) -> BigDecimal
|
|
322
|
+
|
|
323
|
+
# <!--
|
|
324
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
325
|
+
# - BigMath.log1p(decimal, numeric) -> BigDecimal
|
|
326
|
+
# -->
|
|
327
|
+
# Computes log(1 + decimal) to the specified number of digits of precision,
|
|
328
|
+
# `numeric`.
|
|
329
|
+
#
|
|
330
|
+
# BigMath.log1p(BigDecimal('0.1'), 32).to_s
|
|
331
|
+
# #=> "0.95310179804324860043952123280765e-1"
|
|
332
|
+
#
|
|
333
|
+
def self?.log1p: (real | BigDecimal, int prec) -> BigDecimal
|
|
334
|
+
|
|
335
|
+
# <!--
|
|
336
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
337
|
+
# - BigMath.log2(decimal, numeric) -> BigDecimal
|
|
338
|
+
# -->
|
|
339
|
+
# Computes the base 2 logarithm of `decimal` to the specified number of digits
|
|
340
|
+
# of precision, `numeric`.
|
|
341
|
+
#
|
|
342
|
+
# If `decimal` is zero or negative, raises Math::DomainError.
|
|
343
|
+
#
|
|
344
|
+
# If `decimal` is positive infinity, returns Infinity.
|
|
345
|
+
#
|
|
346
|
+
# If `decimal` is NaN, returns NaN.
|
|
347
|
+
#
|
|
348
|
+
# BigMath.log2(BigDecimal('3'), 32).to_s
|
|
349
|
+
# #=> "0.15849625007211561814537389439478e1"
|
|
350
|
+
#
|
|
351
|
+
def self?.log2: (real | BigDecimal, int prec) -> BigDecimal
|
|
352
|
+
|
|
353
|
+
# <!--
|
|
354
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
355
|
+
# - sin(decimal, numeric) -> BigDecimal
|
|
356
|
+
# -->
|
|
357
|
+
# Computes the sine of `decimal` to the specified number of digits of precision,
|
|
358
|
+
# `numeric`.
|
|
359
|
+
#
|
|
360
|
+
# If `decimal` is Infinity or NaN, returns NaN.
|
|
361
|
+
#
|
|
362
|
+
# BigMath.sin(BigMath.PI(5)/4, 32).to_s
|
|
363
|
+
# #=> "0.70710807985947359435812921837984e0"
|
|
364
|
+
#
|
|
365
|
+
def self?.sin: (real | BigDecimal x, int prec) -> BigDecimal
|
|
366
|
+
|
|
367
|
+
# <!--
|
|
368
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
369
|
+
# - sinh(decimal, numeric) -> BigDecimal
|
|
370
|
+
# -->
|
|
371
|
+
# Computes the hyperbolic sine of `decimal` to the specified number of digits of
|
|
372
|
+
# precision, `numeric`.
|
|
373
|
+
#
|
|
374
|
+
# If `decimal` is NaN, returns NaN.
|
|
375
|
+
#
|
|
376
|
+
# BigMath.sinh(BigDecimal('1'), 32).to_s
|
|
377
|
+
# #=> "0.11752011936438014568823818505956e1"
|
|
378
|
+
#
|
|
379
|
+
def self?.sinh: (real | BigDecimal, int prec) -> BigDecimal
|
|
380
|
+
|
|
381
|
+
# <!--
|
|
382
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
383
|
+
# - sqrt(decimal, numeric) -> BigDecimal
|
|
384
|
+
# -->
|
|
385
|
+
# Computes the square root of `decimal` to the specified number of digits of
|
|
386
|
+
# precision, `numeric`.
|
|
387
|
+
#
|
|
388
|
+
# BigMath.sqrt(BigDecimal('2'), 32).to_s
|
|
389
|
+
# #=> "0.14142135623730950488016887242097e1"
|
|
390
|
+
#
|
|
391
|
+
def self?.sqrt: (real | BigDecimal x, int prec) -> BigDecimal
|
|
392
|
+
|
|
393
|
+
# <!--
|
|
394
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
395
|
+
# - tan(decimal, numeric) -> BigDecimal
|
|
396
|
+
# -->
|
|
397
|
+
# Computes the tangent of `decimal` to the specified number of digits of
|
|
398
|
+
# precision, `numeric`.
|
|
399
|
+
#
|
|
400
|
+
# If `decimal` is Infinity or NaN, returns NaN.
|
|
401
|
+
#
|
|
402
|
+
# BigMath.tan(BigDecimal("0.0"), 4).to_s
|
|
403
|
+
# #=> "0.0"
|
|
404
|
+
#
|
|
405
|
+
# BigMath.tan(BigMath.PI(24) / 4, 32).to_s
|
|
406
|
+
# #=> "0.99999999999999999999999830836025e0"
|
|
407
|
+
#
|
|
408
|
+
def self?.tan: (real | BigDecimal x, int prec) -> BigDecimal
|
|
409
|
+
|
|
410
|
+
# <!--
|
|
411
|
+
# rdoc-file=lib/bigdecimal/math.rb
|
|
412
|
+
# - tanh(decimal, numeric) -> BigDecimal
|
|
413
|
+
# -->
|
|
414
|
+
# Computes the hyperbolic tangent of `decimal` to the specified number of digits
|
|
415
|
+
# of precision, `numeric`.
|
|
416
|
+
#
|
|
417
|
+
# If `decimal` is NaN, returns NaN.
|
|
418
|
+
#
|
|
419
|
+
# BigMath.tanh(BigDecimal('1'), 32).to_s
|
|
420
|
+
# #=> "0.76159415595576488811945828260479e0"
|
|
421
|
+
#
|
|
422
|
+
def self?.tanh: (real | BigDecimal, int prec) -> BigDecimal
|
|
423
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bigdecimal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Kenta Murata
|
|
@@ -30,6 +30,9 @@ files:
|
|
|
30
30
|
- sample/linear.rb
|
|
31
31
|
- sample/nlsolve.rb
|
|
32
32
|
- sample/pi.rb
|
|
33
|
+
- sig/big_decimal.rbs
|
|
34
|
+
- sig/big_decimal_util.rbs
|
|
35
|
+
- sig/big_math.rbs
|
|
33
36
|
homepage: https://github.com/ruby/bigdecimal
|
|
34
37
|
licenses:
|
|
35
38
|
- Ruby
|
|
@@ -43,7 +46,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
43
46
|
requirements:
|
|
44
47
|
- - ">="
|
|
45
48
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 2.
|
|
49
|
+
version: 2.6.0
|
|
47
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
51
|
requirements:
|
|
49
52
|
- - ">="
|