bigdecimal 3.1.3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 709b449a675da27c73c3f89a806b30042260e11ff5850a4f67ad2742c5b893db
4
- data.tar.gz: e1e356c06c6af164010886bbbc58f89217921e73d8b5267587c87c9b4566ca75
3
+ metadata.gz: 4107ae2a3ed84ad02b56f2f57c31087185545454e53089e8176a23bd829c5177
4
+ data.tar.gz: 392489743d1863336597fc19039c1fd0077c5735b096de799f8adf61a5c29dbe
5
5
  SHA512:
6
- metadata.gz: a745b78d3b9fe6f4e5a904dbe0e92fe8d30ff82e741835186ef528a92e2532d7cf10a3da6722ecc8b46b16c1a4f4bccb22bd18ccf5e5fedee1bae1bf62d17961
7
- data.tar.gz: 57e4c571d5b1639206842d0ecbfd67ff2b296c9639fdacd5b655b4bf98714e211b737061e95f79f21c4e735afe7e0550079fb6bac3b9f9eefb1ba2c55e48ffbe
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 = "bigdecimal"
5
- s.version = "3.1.3"
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", "bsd-2-clause"]
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
@@ -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
- RB_GC_GUARD(one) = VpCheckGetValue(NewOneWrapLimited(1, 1));
4137
- RB_GC_GUARD(two) = VpCheckGetValue(VpCreateRbObject(1, "2", true));
4145
+ one = VpCheckGetValue(NewOneWrapLimited(1, 1));
4146
+ two = VpCheckGetValue(VpCreateRbObject(1, "2", true));
4138
4147
 
4139
4148
  n = prec + BIGDECIMAL_DOUBLE_FIGURES;
4140
- RB_GC_GUARD(vn) = SSIZET2NUM(n);
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
- RB_GC_GUARD(x2) = BigDecimal_mult2(x, x, vn);
4153
- RB_GC_GUARD(y) = x;
4154
- RB_GC_GUARD(d) = y;
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(RUBY_BIGDECIMAL_VERSION));
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", %lu, %lu)", a->exponent, a->Prec, a->MaxPrec);
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");
@@ -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
@@ -1 +1,5 @@
1
- require 'bigdecimal.so'
1
+ if RUBY_ENGINE == 'jruby'
2
+ JRuby::Util.load_ext("org.jruby.ext.bigdecimal.BigDecimalLibrary")
3
+ else
4
+ require 'bigdecimal.so'
5
+ end
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.3
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: 2022-12-05 00:00:00.000000000 Z
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
- - bsd-2-clause
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.4.0.dev
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: []