bigdecimal 3.1.7 → 3.1.8

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: 8bd666f800ebaf8bf81b991c2220587d621521c6d02548680bfbb4ff55b245b7
4
- data.tar.gz: 15be279642ac5dd98f2470df7a46fc288992b450a1d5f1629d52c701377d191d
3
+ metadata.gz: 2090d7c93ccb0ee94f4e31b443f01a4a996c7f0a12f0684ac21bcdea56813fda
4
+ data.tar.gz: de18780d3080b0251e6f9cb8a0b6b31ea77d38d92874b57eb37efb40cec83997
5
5
  SHA512:
6
- metadata.gz: 123b9d9b3b3a5d9ab3664b2887cee0d846f8b9a1e87d590e06751a844759e31e4286b28ad578e6fb14b4975890ed7179cbfbc660196b6cb3c23f9cb8e7eddb16
7
- data.tar.gz: 6ad102cec32ddceb2c6c19fdb4821bda9fe9c3c0e07b4b3d3eb8b98ce9b3ec60d887d1446efecce0d86675b02d5138a11028ea1bd2cd494ddc3a836082e9ba7a
6
+ metadata.gz: 5a2c8d3e0c57a6bd6e63ffcb5c0a125b9edcb85a4528db302d95bce276e9fadc513727a7a7b9f3bb22a10c305e2b5533c53e60612ed68843456b5d43c4aabd9e
7
+ data.tar.gz: 3b93bfadda8ce3963d2aa61ce1342be2664ea216d029ec24588869a14b12ffb0171538f088490cf8da25fe836361be2d3ff630d514790a0d152bb988c952431e
data/bigdecimal.gemspec CHANGED
@@ -52,4 +52,6 @@ Gem::Specification.new do |s|
52
52
  end
53
53
 
54
54
  s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
55
+
56
+ s.metadata["changelog_uri"] = s.homepage + "/blob/master/CHANGES.md"
55
57
  end
@@ -31,7 +31,7 @@
31
31
  #include "bits.h"
32
32
  #include "static_assert.h"
33
33
 
34
- #define BIGDECIMAL_VERSION "3.1.7"
34
+ #define BIGDECIMAL_VERSION "3.1.8"
35
35
 
36
36
  /* #define ENABLE_NUMERIC_STRING */
37
37
 
@@ -1780,6 +1780,17 @@ BigDecimal_neg(VALUE self)
1780
1780
  return VpCheckGetValue(c);
1781
1781
  }
1782
1782
 
1783
+ /*
1784
+ * call-seq:
1785
+ * a * b -> bigdecimal
1786
+ *
1787
+ * Multiply by the specified value.
1788
+ *
1789
+ * The result precision will be the precision of the sum of each precision.
1790
+ *
1791
+ * See BigDecimal#mult.
1792
+ */
1793
+
1783
1794
  static VALUE
1784
1795
  BigDecimal_mult(VALUE self, VALUE r)
1785
1796
  {
@@ -3257,10 +3268,11 @@ BigDecimal_initialize_copy(VALUE self, VALUE other)
3257
3268
  return self;
3258
3269
  }
3259
3270
 
3271
+ /* :nodoc: */
3260
3272
  static VALUE
3261
3273
  BigDecimal_clone(VALUE self)
3262
3274
  {
3263
- return self;
3275
+ return self;
3264
3276
  }
3265
3277
 
3266
3278
  #ifdef HAVE_RB_OPTS_EXCEPTION_P
@@ -3758,6 +3770,12 @@ f_BigDecimal(int argc, VALUE *argv, VALUE self)
3758
3770
  return rb_convert_to_BigDecimal(val, digs, exception);
3759
3771
  }
3760
3772
 
3773
+ /* call-seq:
3774
+ * BigDecimal.interpret_loosely(string) -> bigdecimal
3775
+ *
3776
+ * Returns the +BigDecimal+ converted loosely from +string+.
3777
+ */
3778
+
3761
3779
  static VALUE
3762
3780
  BigDecimal_s_interpret_loosely(VALUE klass, VALUE str)
3763
3781
  {
@@ -4238,6 +4256,17 @@ BigDecimal_negative_zero(void)
4238
4256
  return BIGDECIMAL_NEGATIVE_ZERO;
4239
4257
  }
4240
4258
 
4259
+ static inline VALUE
4260
+ BigDecimal_literal(const char *str)
4261
+ {
4262
+ VALUE arg = rb_str_new_cstr(str);
4263
+ VALUE val = f_BigDecimal(1, &arg, rb_cBigDecimal);
4264
+ rb_gc_register_mark_object(val);
4265
+ return val;
4266
+ }
4267
+
4268
+ #define BIGDECIMAL_LITERAL(var, val) (BIGDECIMAL_ ## var = BigDecimal_literal(#val))
4269
+
4241
4270
  /* Document-class: BigDecimal
4242
4271
  * BigDecimal provides arbitrary-precision floating point decimal arithmetic.
4243
4272
  *
@@ -4394,7 +4423,6 @@ Init_bigdecimal(void)
4394
4423
  #ifdef HAVE_RB_EXT_RACTOR_SAFE
4395
4424
  rb_ext_ractor_safe(true);
4396
4425
  #endif
4397
- VALUE arg;
4398
4426
 
4399
4427
  id_BigDecimal_exception_mode = rb_intern_const("BigDecimal.exception_mode");
4400
4428
  id_BigDecimal_rounding_mode = rb_intern_const("BigDecimal.rounding_mode");
@@ -4532,33 +4560,19 @@ Init_bigdecimal(void)
4532
4560
  rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE", INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
4533
4561
 
4534
4562
  /* Positive zero value. */
4535
- arg = rb_str_new2("+0");
4536
- BIGDECIMAL_POSITIVE_ZERO = f_BigDecimal(1, &arg, rb_cBigDecimal);
4537
- rb_gc_register_mark_object(BIGDECIMAL_POSITIVE_ZERO);
4563
+ BIGDECIMAL_LITERAL(POSITIVE_ZERO, +0);
4538
4564
 
4539
4565
  /* Negative zero value. */
4540
- arg = rb_str_new2("-0");
4541
- BIGDECIMAL_NEGATIVE_ZERO = f_BigDecimal(1, &arg, rb_cBigDecimal);
4542
- rb_gc_register_mark_object(BIGDECIMAL_NEGATIVE_ZERO);
4566
+ BIGDECIMAL_LITERAL(NEGATIVE_ZERO, -0);
4543
4567
 
4544
- /* Positive infinity value. */
4545
- arg = rb_str_new2("+Infinity");
4546
- BIGDECIMAL_POSITIVE_INFINITY = f_BigDecimal(1, &arg, rb_cBigDecimal);
4547
- rb_gc_register_mark_object(BIGDECIMAL_POSITIVE_INFINITY);
4568
+ /* Positive infinity[rdoc-ref:BigDecimal@Infinity] value. */
4569
+ rb_define_const(rb_cBigDecimal, "INFINITY", BIGDECIMAL_LITERAL(POSITIVE_INFINITY, +Infinity));
4548
4570
 
4549
4571
  /* Negative infinity value. */
4550
- arg = rb_str_new2("-Infinity");
4551
- BIGDECIMAL_NEGATIVE_INFINITY = f_BigDecimal(1, &arg, rb_cBigDecimal);
4552
- rb_gc_register_mark_object(BIGDECIMAL_NEGATIVE_INFINITY);
4572
+ BIGDECIMAL_LITERAL(NEGATIVE_INFINITY, -Infinity);
4553
4573
 
4554
- /* 'Not a Number' value. */
4555
- arg = rb_str_new2("NaN");
4556
- BIGDECIMAL_NAN = f_BigDecimal(1, &arg, rb_cBigDecimal);
4557
- rb_gc_register_mark_object(BIGDECIMAL_NAN);
4558
-
4559
- /* Special value constants */
4560
- rb_define_const(rb_cBigDecimal, "INFINITY", BIGDECIMAL_POSITIVE_INFINITY);
4561
- rb_define_const(rb_cBigDecimal, "NAN", BIGDECIMAL_NAN);
4574
+ /* '{Not a Number}[rdoc-ref:BigDecimal@Not+a+Number]' value. */
4575
+ rb_define_const(rb_cBigDecimal, "NAN", BIGDECIMAL_LITERAL(NAN, NaN));
4562
4576
 
4563
4577
  /* instance methods */
4564
4578
  rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
@@ -5203,6 +5217,48 @@ bigdecimal_parse_special_string(const char *str)
5203
5217
  return NULL;
5204
5218
  }
5205
5219
 
5220
+ struct VpCtoV_args {
5221
+ Real *a;
5222
+ const char *int_chr;
5223
+ size_t ni;
5224
+ const char *frac;
5225
+ size_t nf;
5226
+ const char *exp_chr;
5227
+ size_t ne;
5228
+ };
5229
+
5230
+ static VALUE
5231
+ call_VpCtoV(VALUE arg)
5232
+ {
5233
+ struct VpCtoV_args *x = (struct VpCtoV_args *)arg;
5234
+ return (VALUE)VpCtoV(x->a, x->int_chr, x->ni, x->frac, x->nf, x->exp_chr, x->ne);
5235
+ }
5236
+
5237
+ static int
5238
+ protected_VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne, int free_on_error)
5239
+ {
5240
+ struct VpCtoV_args args;
5241
+ int state = 0;
5242
+
5243
+ args.a = a;
5244
+ args.int_chr = int_chr;
5245
+ args.ni = ni;
5246
+ args.frac = frac;
5247
+ args.nf = nf;
5248
+ args.exp_chr = exp_chr;
5249
+ args.ne = ne;
5250
+
5251
+ VALUE result = rb_protect(call_VpCtoV, (VALUE)&args, &state);
5252
+ if (state) {
5253
+ if (free_on_error) {
5254
+ rbd_free_struct(a);
5255
+ }
5256
+ rb_jump_tag(state);
5257
+ }
5258
+
5259
+ return (int)result;
5260
+ }
5261
+
5206
5262
  /*
5207
5263
  * Allocates variable.
5208
5264
  * [Input]
@@ -5422,7 +5478,7 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
5422
5478
  vp = rbd_allocate_struct(len);
5423
5479
  vp->MaxPrec = len; /* set max precision */
5424
5480
  VpSetZero(vp, sign);
5425
- VpCtoV(vp, psz, ni, psz + ipf, nf, psz + ipe, ne);
5481
+ protected_VpCtoV(vp, psz, ni, psz + ipf, nf, psz + ipe, ne, true);
5426
5482
  rb_str_resize(buf, 0);
5427
5483
  return vp;
5428
5484
  }
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigdecimal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.7
4
+ version: 3.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
8
8
  - Zachary Scott
9
9
  - Shigeo Kobayashi
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2024-03-14 00:00:00.000000000 Z
13
+ date: 2024-05-07 00:00:00.000000000 Z
13
14
  dependencies: []
14
15
  description: This library provides arbitrary-precision decimal floating-point number
15
16
  class.
@@ -44,7 +45,9 @@ homepage: https://github.com/ruby/bigdecimal
44
45
  licenses:
45
46
  - Ruby
46
47
  - BSD-2-Clause
47
- metadata: {}
48
+ metadata:
49
+ changelog_uri: https://github.com/ruby/bigdecimal/blob/master/CHANGES.md
50
+ post_install_message:
48
51
  rdoc_options: []
49
52
  require_paths:
50
53
  - lib
@@ -59,7 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
62
  - !ruby/object:Gem::Version
60
63
  version: '0'
61
64
  requirements: []
62
- rubygems_version: 3.6.0.dev
65
+ rubygems_version: 3.5.9
66
+ signing_key:
63
67
  specification_version: 4
64
68
  summary: Arbitrary-precision decimal floating-point number library.
65
69
  test_files: []