bigdecimal 1.3.5 → 3.0.0
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 -6
- data/ext/bigdecimal/bigdecimal.c +542 -249
- data/ext/bigdecimal/bigdecimal.h +5 -1
- data/ext/bigdecimal/extconf.rb +30 -6
- data/lib/bigdecimal.rb +1 -0
- data/lib/bigdecimal/jacobian.rb +3 -1
- data/lib/bigdecimal/util.rb +37 -7
- metadata +10 -25
- data/ext/bigdecimal/depend +0 -13
data/ext/bigdecimal/bigdecimal.h
CHANGED
@@ -159,6 +159,10 @@ rb_sym2str(VALUE sym)
|
|
159
159
|
# define vabs llabs
|
160
160
|
#endif
|
161
161
|
|
162
|
+
#if !defined(HAVE_RB_CATEGORY_WARN) || !defined(HAVE_CONST_RB_WARN_CATEGORY_DEPRECATED)
|
163
|
+
# define rb_category_warn(category, ...) rb_warn(__VA_ARGS__)
|
164
|
+
#endif
|
165
|
+
|
162
166
|
extern VALUE rb_cBigDecimal;
|
163
167
|
|
164
168
|
#if 0 || SIZEOF_BDIGITS >= 16
|
@@ -308,7 +312,7 @@ VP_EXPORT size_t VpInit(BDIGIT BaseVal);
|
|
308
312
|
VP_EXPORT void *VpMemAlloc(size_t mb);
|
309
313
|
VP_EXPORT void *VpMemRealloc(void *ptr, size_t mb);
|
310
314
|
VP_EXPORT void VpFree(Real *pv);
|
311
|
-
VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal);
|
315
|
+
VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal, int strict_p, int exc);
|
312
316
|
VP_EXPORT size_t VpAsgn(Real *c, Real *a, int isw);
|
313
317
|
VP_EXPORT size_t VpAddSub(Real *c,Real *a,Real *b,int operation);
|
314
318
|
VP_EXPORT size_t VpMult(Real *c,Real *a,Real *b);
|
data/ext/bigdecimal/extconf.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
require 'mkmf'
|
3
3
|
|
4
|
+
def check_bigdecimal_version(gemspec_path)
|
5
|
+
message "checking RUBY_BIGDECIMAL_VERSION... "
|
6
|
+
|
7
|
+
bigdecimal_version =
|
8
|
+
IO.readlines(gemspec_path)
|
9
|
+
.grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([^\']+)\'/, 1]
|
10
|
+
|
11
|
+
version_components = bigdecimal_version.split('.')
|
12
|
+
bigdecimal_version = version_components[0, 3].join('.')
|
13
|
+
bigdecimal_version << "-#{version_components[3]}" if version_components[3]
|
14
|
+
$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
|
15
|
+
|
16
|
+
message "#{bigdecimal_version}\n"
|
17
|
+
end
|
18
|
+
|
4
19
|
gemspec_name = gemspec_path = nil
|
5
20
|
unless ['', '../../'].any? {|dir|
|
6
21
|
gemspec_name = "#{dir}bigdecimal.gemspec"
|
@@ -11,11 +26,7 @@ unless ['', '../../'].any? {|dir|
|
|
11
26
|
abort
|
12
27
|
end
|
13
28
|
|
14
|
-
|
15
|
-
IO.readlines(gemspec_path)
|
16
|
-
.grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([\d\.]+)\'/, 1]
|
17
|
-
|
18
|
-
$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
|
29
|
+
check_bigdecimal_version(gemspec_path)
|
19
30
|
|
20
31
|
have_func("labs", "stdlib.h")
|
21
32
|
have_func("llabs", "stdlib.h")
|
@@ -25,9 +36,22 @@ have_func("isfinite", "math.h")
|
|
25
36
|
have_type("struct RRational", "ruby.h")
|
26
37
|
have_func("rb_rational_num", "ruby.h")
|
27
38
|
have_func("rb_rational_den", "ruby.h")
|
39
|
+
have_type("struct RComplex", "ruby.h")
|
40
|
+
have_func("rb_complex_real", "ruby.h")
|
41
|
+
have_func("rb_complex_imag", "ruby.h")
|
28
42
|
have_func("rb_array_const_ptr", "ruby.h")
|
29
43
|
have_func("rb_sym2str", "ruby.h")
|
44
|
+
have_func("rb_opts_exception_p", "ruby.h")
|
45
|
+
have_func("rb_category_warn", "ruby.h")
|
46
|
+
have_const("RB_WARN_CATEGORY_DEPRECATED", "ruby.h")
|
47
|
+
|
48
|
+
if File.file?(File.expand_path('../lib/bigdecimal.rb', __FILE__))
|
49
|
+
bigdecimal_rb = "$(srcdir)/lib/bigdecimal.rb"
|
50
|
+
else
|
51
|
+
bigdecimal_rb = "$(srcdir)/../../lib/bigdecimal.rb"
|
52
|
+
end
|
30
53
|
|
31
54
|
create_makefile('bigdecimal') {|mf|
|
32
|
-
mf << "
|
55
|
+
mf << "GEMSPEC = #{gemspec_name}\n"
|
56
|
+
mf << "BIGDECIMAL_RB = #{bigdecimal_rb}\n"
|
33
57
|
}
|
data/lib/bigdecimal.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bigdecimal.so'
|
data/lib/bigdecimal/jacobian.rb
CHANGED
data/lib/bigdecimal/util.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
# and provides BigDecimal#to_d and BigDecimal#to_digits.
|
6
6
|
#++
|
7
7
|
|
8
|
+
require 'bigdecimal'
|
8
9
|
|
9
10
|
class Integer < Numeric
|
10
11
|
# call-seq:
|
@@ -42,8 +43,8 @@ class Float < Numeric
|
|
42
43
|
#
|
43
44
|
# See also BigDecimal::new.
|
44
45
|
#
|
45
|
-
def to_d(precision=
|
46
|
-
BigDecimal(self, precision
|
46
|
+
def to_d(precision=Float::DIG+1)
|
47
|
+
BigDecimal(self, precision)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
@@ -65,11 +66,7 @@ class String
|
|
65
66
|
# See also BigDecimal::new.
|
66
67
|
#
|
67
68
|
def to_d
|
68
|
-
|
69
|
-
BigDecimal(self)
|
70
|
-
rescue ArgumentError
|
71
|
-
BigDecimal(0)
|
72
|
-
end
|
69
|
+
BigDecimal.interpret_loosely(self)
|
73
70
|
end
|
74
71
|
end
|
75
72
|
|
@@ -134,6 +131,39 @@ class Rational < Numeric
|
|
134
131
|
end
|
135
132
|
|
136
133
|
|
134
|
+
class Complex < Numeric
|
135
|
+
# call-seq:
|
136
|
+
# cmp.to_d -> bigdecimal
|
137
|
+
# cmp.to_d(precision) -> bigdecimal
|
138
|
+
#
|
139
|
+
# Returns the value as a BigDecimal.
|
140
|
+
#
|
141
|
+
# The +precision+ parameter is required for a rational complex number.
|
142
|
+
# This parameter is used to determine the number of significant digits
|
143
|
+
# for the result.
|
144
|
+
#
|
145
|
+
# require 'bigdecimal'
|
146
|
+
# require 'bigdecimal/util'
|
147
|
+
#
|
148
|
+
# Complex(0.1234567, 0).to_d(4) # => 0.1235e0
|
149
|
+
# Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
|
150
|
+
#
|
151
|
+
# See also BigDecimal::new.
|
152
|
+
#
|
153
|
+
def to_d(*args)
|
154
|
+
BigDecimal(self) unless self.imag.zero? # to raise eerror
|
155
|
+
|
156
|
+
if args.length == 0
|
157
|
+
case self.real
|
158
|
+
when Rational
|
159
|
+
BigDecimal(self.real) # to raise error
|
160
|
+
end
|
161
|
+
end
|
162
|
+
self.real.to_d(*args)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
|
137
167
|
class NilClass
|
138
168
|
# call-seq:
|
139
169
|
# nil.to_d -> bigdecimal
|
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
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Murata
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-12-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 12.3.3
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 12.3.3
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake-compiler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,20 +40,6 @@ dependencies:
|
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0.9'
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: rake-compiler-dock
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 0.6.1
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.6.1
|
57
43
|
- !ruby/object:Gem::Dependency
|
58
44
|
name: minitest
|
59
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,8 +80,8 @@ files:
|
|
94
80
|
- bigdecimal.gemspec
|
95
81
|
- ext/bigdecimal/bigdecimal.c
|
96
82
|
- ext/bigdecimal/bigdecimal.h
|
97
|
-
- ext/bigdecimal/depend
|
98
83
|
- ext/bigdecimal/extconf.rb
|
84
|
+
- lib/bigdecimal.rb
|
99
85
|
- lib/bigdecimal/jacobian.rb
|
100
86
|
- lib/bigdecimal/ludcmp.rb
|
101
87
|
- lib/bigdecimal/math.rb
|
@@ -106,7 +92,7 @@ files:
|
|
106
92
|
- sample/pi.rb
|
107
93
|
homepage: https://github.com/ruby/bigdecimal
|
108
94
|
licenses:
|
109
|
-
-
|
95
|
+
- Ruby
|
110
96
|
metadata: {}
|
111
97
|
post_install_message:
|
112
98
|
rdoc_options: []
|
@@ -116,15 +102,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
102
|
requirements:
|
117
103
|
- - ">="
|
118
104
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
105
|
+
version: 2.4.0
|
120
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.7.6
|
112
|
+
rubygems_version: 3.2.2
|
128
113
|
signing_key:
|
129
114
|
specification_version: 4
|
130
115
|
summary: Arbitrary-precision decimal floating-point number library.
|
data/ext/bigdecimal/depend
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# AUTOGENERATED DEPENDENCIES START
|
2
|
-
bigdecimal.o: $(RUBY_EXTCONF_H)
|
3
|
-
bigdecimal.o: $(arch_hdrdir)/ruby/config.h
|
4
|
-
bigdecimal.o: $(hdrdir)/ruby/defines.h
|
5
|
-
bigdecimal.o: $(hdrdir)/ruby/intern.h
|
6
|
-
bigdecimal.o: $(hdrdir)/ruby/missing.h
|
7
|
-
bigdecimal.o: $(hdrdir)/ruby/ruby.h
|
8
|
-
bigdecimal.o: $(hdrdir)/ruby/st.h
|
9
|
-
bigdecimal.o: $(hdrdir)/ruby/subst.h
|
10
|
-
bigdecimal.o: $(hdrdir)/ruby/util.h
|
11
|
-
bigdecimal.o: bigdecimal.c
|
12
|
-
bigdecimal.o: bigdecimal.h
|
13
|
-
# AUTOGENERATED DEPENDENCIES END
|