bigdecimal 3.1.3 → 3.1.4
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 +28 -12
- data/ext/bigdecimal/bigdecimal.c +25 -12
- data/ext/bigdecimal/extconf.rb +0 -25
- data/lib/bigdecimal.rb +5 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4107ae2a3ed84ad02b56f2f57c31087185545454e53089e8176a23bd829c5177
|
4
|
+
data.tar.gz: 392489743d1863336597fc19039c1fd0077c5735b096de799f8adf61a5c29dbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 337fb13844251d627cecd341da3bc0a23b0addcc0b83f49f76e3fc0796852e24d71291712b270c79e3cb9e729bd2d831e4ca303a46dd4c7446404de6175b1f86
|
7
|
+
data.tar.gz: 4d2b9734294ff4f154df4012bd8f21964e3627b29ade7c716079ad6a74c19713a0a0a287cb57315d642cac7fe9b521db21104e9ea89eef745babcf292b7a67d2
|
data/bigdecimal.gemspec
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
name = File.basename(__FILE__, '.*')
|
4
|
+
source_version = ["", "ext/#{name}/"].find do |dir|
|
5
|
+
begin
|
6
|
+
break File.foreach(File.join(__dir__, "#{dir}#{name}.c")) {|line|
|
7
|
+
break $1.sub("-", ".") if /^#define\s+#{name.upcase}_VERSION\s+"(.+)"/o =~ line
|
8
|
+
}
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
end
|
11
|
+
end or raise "can't find #{name.upcase}_VERSION"
|
12
|
+
|
3
13
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version =
|
14
|
+
s.name = name
|
15
|
+
s.version = source_version
|
6
16
|
s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
|
7
17
|
s.email = ["mrkn@mrkn.jp"]
|
8
18
|
|
9
19
|
s.summary = "Arbitrary-precision decimal floating-point number library."
|
10
20
|
s.description = "This library provides arbitrary-precision decimal floating-point number class."
|
11
21
|
s.homepage = "https://github.com/ruby/bigdecimal"
|
12
|
-
s.licenses = ["Ruby", "
|
22
|
+
s.licenses = ["Ruby", "BSD-2-Clause"]
|
13
23
|
|
14
24
|
s.require_paths = %w[lib]
|
15
|
-
s.extensions = %w[ext/bigdecimal/extconf.rb]
|
16
25
|
s.files = %w[
|
17
26
|
bigdecimal.gemspec
|
18
|
-
ext/bigdecimal/bigdecimal.c
|
19
|
-
ext/bigdecimal/bigdecimal.h
|
20
|
-
ext/bigdecimal/bits.h
|
21
|
-
ext/bigdecimal/feature.h
|
22
|
-
ext/bigdecimal/missing.c
|
23
|
-
ext/bigdecimal/missing.h
|
24
|
-
ext/bigdecimal/missing/dtoa.c
|
25
|
-
ext/bigdecimal/static_assert.h
|
26
27
|
lib/bigdecimal.rb
|
27
28
|
lib/bigdecimal/jacobian.rb
|
28
29
|
lib/bigdecimal/ludcmp.rb
|
@@ -33,6 +34,21 @@ Gem::Specification.new do |s|
|
|
33
34
|
sample/nlsolve.rb
|
34
35
|
sample/pi.rb
|
35
36
|
]
|
37
|
+
if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby'
|
38
|
+
s.platform = 'java'
|
39
|
+
else
|
40
|
+
s.extensions = %w[ext/bigdecimal/extconf.rb]
|
41
|
+
s.files += %w[
|
42
|
+
ext/bigdecimal/bigdecimal.c
|
43
|
+
ext/bigdecimal/bigdecimal.h
|
44
|
+
ext/bigdecimal/bits.h
|
45
|
+
ext/bigdecimal/feature.h
|
46
|
+
ext/bigdecimal/missing.c
|
47
|
+
ext/bigdecimal/missing.h
|
48
|
+
ext/bigdecimal/missing/dtoa.c
|
49
|
+
ext/bigdecimal/static_assert.h
|
50
|
+
]
|
51
|
+
end
|
36
52
|
|
37
53
|
s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
38
54
|
end
|
data/ext/bigdecimal/bigdecimal.c
CHANGED
@@ -31,6 +31,8 @@
|
|
31
31
|
#include "bits.h"
|
32
32
|
#include "static_assert.h"
|
33
33
|
|
34
|
+
#define BIGDECIMAL_VERSION "3.1.4"
|
35
|
+
|
34
36
|
/* #define ENABLE_NUMERIC_STRING */
|
35
37
|
|
36
38
|
#define SIGNED_VALUE_MAX INTPTR_MAX
|
@@ -313,7 +315,7 @@ static const rb_data_type_t BigDecimal_data_type = {
|
|
313
315
|
"BigDecimal",
|
314
316
|
{ 0, BigDecimal_delete, BigDecimal_memsize, },
|
315
317
|
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
316
|
-
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE
|
318
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED
|
317
319
|
#endif
|
318
320
|
};
|
319
321
|
|
@@ -2082,6 +2084,13 @@ BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
|
|
2082
2084
|
if (!b) return DoSomeOne(self, r, rb_intern("remainder"));
|
2083
2085
|
SAVE(b);
|
2084
2086
|
|
2087
|
+
if (VpIsPosInf(b) || VpIsNegInf(b)) {
|
2088
|
+
GUARD_OBJ(*dv, NewZeroWrapLimited(1, 1));
|
2089
|
+
VpSetZero(*dv, 1);
|
2090
|
+
*rv = a;
|
2091
|
+
return Qnil;
|
2092
|
+
}
|
2093
|
+
|
2085
2094
|
mx = (a->MaxPrec + b->MaxPrec) *VpBaseFig();
|
2086
2095
|
GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
|
2087
2096
|
GUARD_OBJ(res, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1)));
|
@@ -4133,11 +4142,11 @@ get_vp_value:
|
|
4133
4142
|
}
|
4134
4143
|
x = VpCheckGetValue(vx);
|
4135
4144
|
|
4136
|
-
|
4137
|
-
|
4145
|
+
one = VpCheckGetValue(NewOneWrapLimited(1, 1));
|
4146
|
+
two = VpCheckGetValue(VpCreateRbObject(1, "2", true));
|
4138
4147
|
|
4139
4148
|
n = prec + BIGDECIMAL_DOUBLE_FIGURES;
|
4140
|
-
|
4149
|
+
vn = SSIZET2NUM(n);
|
4141
4150
|
expo = VpExponent10(vx);
|
4142
4151
|
if (expo < 0 || expo >= 3) {
|
4143
4152
|
char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4];
|
@@ -4149,9 +4158,9 @@ get_vp_value:
|
|
4149
4158
|
}
|
4150
4159
|
w = BigDecimal_sub(x, one);
|
4151
4160
|
x = BigDecimal_div2(w, BigDecimal_add(x, one), vn);
|
4152
|
-
|
4153
|
-
|
4154
|
-
|
4161
|
+
x2 = BigDecimal_mult2(x, x, vn);
|
4162
|
+
y = x;
|
4163
|
+
d = y;
|
4155
4164
|
i = 1;
|
4156
4165
|
while (!VpIsZero((Real*)DATA_PTR(d))) {
|
4157
4166
|
SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
|
@@ -4179,6 +4188,13 @@ get_vp_value:
|
|
4179
4188
|
y = BigDecimal_add(y, dy);
|
4180
4189
|
}
|
4181
4190
|
|
4191
|
+
RB_GC_GUARD(one);
|
4192
|
+
RB_GC_GUARD(two);
|
4193
|
+
RB_GC_GUARD(vn);
|
4194
|
+
RB_GC_GUARD(x2);
|
4195
|
+
RB_GC_GUARD(y);
|
4196
|
+
RB_GC_GUARD(d);
|
4197
|
+
|
4182
4198
|
return y;
|
4183
4199
|
}
|
4184
4200
|
|
@@ -4395,13 +4411,10 @@ Init_bigdecimal(void)
|
|
4395
4411
|
|
4396
4412
|
/* Constants definition */
|
4397
4413
|
|
4398
|
-
#ifndef RUBY_BIGDECIMAL_VERSION
|
4399
|
-
# error RUBY_BIGDECIMAL_VERSION is not defined
|
4400
|
-
#endif
|
4401
4414
|
/*
|
4402
4415
|
* The version of bigdecimal library
|
4403
4416
|
*/
|
4404
|
-
rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(
|
4417
|
+
rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(BIGDECIMAL_VERSION));
|
4405
4418
|
|
4406
4419
|
/*
|
4407
4420
|
* Base value used in internal calculations. On a 32 bit system, BASE
|
@@ -6453,7 +6466,7 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
|
6453
6466
|
}
|
6454
6467
|
}
|
6455
6468
|
nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a));
|
6456
|
-
nc += fprintf(fp, " (%"PRIdVALUE", %
|
6469
|
+
nc += fprintf(fp, " (%"PRIdVALUE", %"PRIuSIZE", %"PRIuSIZE")", a->exponent, a->Prec, a->MaxPrec);
|
6457
6470
|
}
|
6458
6471
|
else {
|
6459
6472
|
nc += fprintf(fp, "0.0");
|
data/ext/bigdecimal/extconf.rb
CHANGED
@@ -1,18 +1,6 @@
|
|
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
|
-
bigdecimal_version = File.read(gemspec_path).match(/^\s*s\.version\s+=\s+['"]([^'"]+)['"]\s*$/)[1]
|
7
|
-
|
8
|
-
version_components = bigdecimal_version.split('.')
|
9
|
-
bigdecimal_version = version_components[0, 3].join('.')
|
10
|
-
bigdecimal_version << "-#{version_components[3]}" if version_components[3]
|
11
|
-
$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
|
12
|
-
|
13
|
-
message "#{bigdecimal_version}\n"
|
14
|
-
end
|
15
|
-
|
16
4
|
def have_builtin_func(name, check_expr, opt = "", &b)
|
17
5
|
checking_for checking_message(name.funcall_style, nil, opt) do
|
18
6
|
if try_compile(<<SRC, opt, &b)
|
@@ -27,18 +15,6 @@ SRC
|
|
27
15
|
end
|
28
16
|
end
|
29
17
|
|
30
|
-
gemspec_name = gemspec_path = nil
|
31
|
-
unless ['', '../../'].any? {|dir|
|
32
|
-
gemspec_name = "#{dir}bigdecimal.gemspec"
|
33
|
-
gemspec_path = File.expand_path("../#{gemspec_name}", __FILE__)
|
34
|
-
File.file?(gemspec_path)
|
35
|
-
}
|
36
|
-
$stderr.puts "Unable to find bigdecimal.gemspec"
|
37
|
-
abort
|
38
|
-
end
|
39
|
-
|
40
|
-
check_bigdecimal_version(gemspec_path)
|
41
|
-
|
42
18
|
have_builtin_func("__builtin_clz", "__builtin_clz(0)")
|
43
19
|
have_builtin_func("__builtin_clzl", "__builtin_clzl(0)")
|
44
20
|
have_builtin_func("__builtin_clzll", "__builtin_clzll(0)")
|
@@ -82,6 +58,5 @@ else
|
|
82
58
|
end
|
83
59
|
|
84
60
|
create_makefile('bigdecimal') {|mf|
|
85
|
-
mf << "GEMSPEC = #{gemspec_name}\n"
|
86
61
|
mf << "BIGDECIMAL_RB = #{bigdecimal_rb}\n"
|
87
62
|
}
|
data/lib/bigdecimal.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigdecimal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Murata
|
8
8
|
- Zachary Scott
|
9
9
|
- Shigeo Kobayashi
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: This library provides arbitrary-precision decimal floating-point number
|
16
16
|
class.
|
@@ -43,9 +43,9 @@ files:
|
|
43
43
|
homepage: https://github.com/ruby/bigdecimal
|
44
44
|
licenses:
|
45
45
|
- Ruby
|
46
|
-
-
|
46
|
+
- BSD-2-Clause
|
47
47
|
metadata: {}
|
48
|
-
post_install_message:
|
48
|
+
post_install_message:
|
49
49
|
rdoc_options: []
|
50
50
|
require_paths:
|
51
51
|
- lib
|
@@ -60,8 +60,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
64
|
-
signing_key:
|
63
|
+
rubygems_version: 3.3.13
|
64
|
+
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Arbitrary-precision decimal floating-point number library.
|
67
67
|
test_files: []
|