bigdecimal 1.3.2 → 1.3.3

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
  SHA1:
3
- metadata.gz: e74979e928a1faa6ecca707c8d405be6e4c0b6d5
4
- data.tar.gz: f8fb2859efdaa6a9ff49ae0d9d0cc2471ff2f89e
3
+ metadata.gz: 58d7e0c80b71e36acf67381960d3bdf551aa713c
4
+ data.tar.gz: 296291e66a2b2d04e5ac9bbb5f55fc72dda16fb4
5
5
  SHA512:
6
- metadata.gz: 585f1a41327c0265d6dbe79ea5934d92381d75c07f3305fe284d226f7e3315d15db6003441356b2e374ef2cd6909f2d5ce64df23604e1763f1d1340690ccc739
7
- data.tar.gz: ccf79300c8b45bd8bed8f240f72ee6aa43c14bec8944e1b6871fdba9639d40b53da6a4a31072f05cee66703f57102946fec9e7cfb161d8ea10bb200e185c166f
6
+ metadata.gz: 70767732235c4c5594e75a2c6aeb44d5c37d4e9eaad3972744dcad4f1c236d30d872b610ee199243144d743c59a4a395532eee0f95024403f099e58338177084
7
+ data.tar.gz: 3ccbceef117a07b0cac34d0f23598a1728e94277b9a765b99458ba7d1fe7ba36cb90cac98568ced6adc84c56c6152af46d7cdc325962a0513781504967e932f5
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
- _VERSION = '1.3.2'
2
+
3
+ bigdecimal_version = '1.3.3'
3
4
 
4
5
  Gem::Specification.new do |s|
5
6
  s.name = "bigdecimal"
6
- s.version = _VERSION
7
+ s.version = bigdecimal_version
7
8
  s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
8
9
  s.email = ["mrkn@mrkn.jp"]
9
10
 
@@ -31,7 +32,8 @@ Gem::Specification.new do |s|
31
32
  ]
32
33
 
33
34
  s.add_development_dependency "rake", "~> 10.0"
34
- s.add_development_dependency "rake-compiler", "~> 0.9"
35
+ s.add_development_dependency "rake-compiler", ">= 0.9"
36
+ s.add_development_dependency "rake-compiler-dock", ">= 0.6.1"
35
37
  s.add_development_dependency "minitest", "~> 4.7.5"
36
38
  s.add_development_dependency "pry"
37
39
  end
@@ -141,12 +141,16 @@ rb_rational_den(VALUE rat)
141
141
  static VALUE
142
142
  BigDecimal_version(VALUE self)
143
143
  {
144
- /*
145
- * 1.0.0: Ruby 1.8.0
146
- * 1.0.1: Ruby 1.8.1
147
- * 1.1.0: Ruby 1.9.3
148
- */
149
- return rb_str_new2("1.1.0");
144
+ /*
145
+ * 1.0.0: Ruby 1.8.0
146
+ * 1.0.1: Ruby 1.8.1
147
+ * 1.1.0: Ruby 1.9.3
148
+ */
149
+ #ifndef RUBY_BIGDECIMAL_VERSION
150
+ # error RUBY_BIGDECIMAL_VERSION is not defined
151
+ #endif
152
+ rb_warning("BigDecimal.ver is deprecated; use BigDecimal::VERSION instead.");
153
+ return rb_str_new2(RUBY_BIGDECIMAL_VERSION);
150
154
  }
151
155
 
152
156
  /*
@@ -289,8 +293,9 @@ again:
289
293
 
290
294
  #ifdef ENABLE_NUMERIC_STRING
291
295
  case T_STRING:
292
- SafeStringValue(v);
293
- return VpCreateRbObject(strlen(RSTRING_PTR(v)) + VpBaseFig() + 1,
296
+ StringValueCStr(v);
297
+ rb_check_safe_obj(v);
298
+ return VpCreateRbObject(RSTRING_LEN(v) + VpBaseFig() + 1,
294
299
  RSTRING_PTR(v));
295
300
  #endif /* ENABLE_NUMERIC_STRING */
296
301
 
@@ -384,7 +389,7 @@ BigDecimal_hash(VALUE self)
384
389
  hash ^= rb_memhash(p->frac, sizeof(BDIGIT)*p->Prec);
385
390
  hash += p->exponent;
386
391
  }
387
- return INT2FIX(hash);
392
+ return ST2FIX(hash);
388
393
  }
389
394
 
390
395
  /*
@@ -392,7 +397,7 @@ BigDecimal_hash(VALUE self)
392
397
  *
393
398
  * Method used to provide marshalling support.
394
399
  *
395
- * inf = BigDecimal.new('Infinity')
400
+ * inf = BigDecimal('Infinity')
396
401
  * #=> Infinity
397
402
  * BigDecimal._load(inf._dump)
398
403
  * #=> Infinity
@@ -430,8 +435,8 @@ BigDecimal_load(VALUE self, VALUE str)
430
435
  unsigned char ch;
431
436
  unsigned long m=0;
432
437
 
433
- SafeStringValue(str);
434
- pch = (unsigned char *)RSTRING_PTR(str);
438
+ pch = (unsigned char *)StringValueCStr(str);
439
+ rb_check_safe_obj(str);
435
440
  /* First get max prec */
436
441
  while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') {
437
442
  if(!ISDIGIT(ch)) {
@@ -645,12 +650,12 @@ GetAddSubPrec(Real *a, Real *b)
645
650
  }
646
651
 
647
652
  static SIGNED_VALUE
648
- GetPositiveInt(VALUE v)
653
+ GetPrecisionInt(VALUE v)
649
654
  {
650
655
  SIGNED_VALUE n;
651
656
  n = NUM2INT(v);
652
657
  if (n < 0) {
653
- rb_raise(rb_eArgError, "argument must be positive");
658
+ rb_raise(rb_eArgError, "negative precision");
654
659
  }
655
660
  return n;
656
661
  }
@@ -875,7 +880,7 @@ BigDecimal_to_r(VALUE self)
875
880
  * be coerced into a BigDecimal value.
876
881
  *
877
882
  * e.g.
878
- * a = BigDecimal.new("1.0")
883
+ * a = BigDecimal("1.0")
879
884
  * b = a / 2.0 #=> 0.5
880
885
  *
881
886
  * Note that coercing a String to a BigDecimal is not supported by default;
@@ -1164,7 +1169,7 @@ BigDecimal_comp(VALUE self, VALUE r)
1164
1169
  *
1165
1170
  * Values may be coerced to perform the comparison:
1166
1171
  *
1167
- * BigDecimal.new('1.0') == 1.0 #=> true
1172
+ * BigDecimal('1.0') == 1.0 #=> true
1168
1173
  */
1169
1174
  static VALUE
1170
1175
  BigDecimal_eq(VALUE self, VALUE r)
@@ -1526,8 +1531,8 @@ BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
1526
1531
  *
1527
1532
  * require 'bigdecimal'
1528
1533
  *
1529
- * a = BigDecimal.new("42")
1530
- * b = BigDecimal.new("9")
1534
+ * a = BigDecimal("42")
1535
+ * b = BigDecimal("9")
1531
1536
  *
1532
1537
  * q, m = a.divmod(b)
1533
1538
  *
@@ -1570,7 +1575,7 @@ BigDecimal_div2(VALUE self, VALUE b, VALUE n)
1570
1575
  }
1571
1576
 
1572
1577
  /* div in BigDecimal sense */
1573
- ix = GetPositiveInt(n);
1578
+ ix = GetPrecisionInt(n);
1574
1579
  if (ix == 0) {
1575
1580
  return BigDecimal_div(self, b);
1576
1581
  }
@@ -1639,7 +1644,7 @@ BigDecimal_add2(VALUE self, VALUE b, VALUE n)
1639
1644
  {
1640
1645
  ENTER(2);
1641
1646
  Real *cv;
1642
- SIGNED_VALUE mx = GetPositiveInt(n);
1647
+ SIGNED_VALUE mx = GetPrecisionInt(n);
1643
1648
  if (mx == 0) return BigDecimal_add(self, b);
1644
1649
  else {
1645
1650
  size_t pl = VpSetPrecLimit(0);
@@ -1669,7 +1674,7 @@ BigDecimal_sub2(VALUE self, VALUE b, VALUE n)
1669
1674
  {
1670
1675
  ENTER(2);
1671
1676
  Real *cv;
1672
- SIGNED_VALUE mx = GetPositiveInt(n);
1677
+ SIGNED_VALUE mx = GetPrecisionInt(n);
1673
1678
  if (mx == 0) return BigDecimal_sub(self, b);
1674
1679
  else {
1675
1680
  size_t pl = VpSetPrecLimit(0);
@@ -1687,7 +1692,7 @@ BigDecimal_mult2(VALUE self, VALUE b, VALUE n)
1687
1692
  {
1688
1693
  ENTER(2);
1689
1694
  Real *cv;
1690
- SIGNED_VALUE mx = GetPositiveInt(n);
1695
+ SIGNED_VALUE mx = GetPrecisionInt(n);
1691
1696
  if (mx == 0) return BigDecimal_mult(self, b);
1692
1697
  else {
1693
1698
  size_t pl = VpSetPrecLimit(0);
@@ -1741,7 +1746,7 @@ BigDecimal_sqrt(VALUE self, VALUE nFig)
1741
1746
  GUARD_OBJ(a, GetVpValue(self, 1));
1742
1747
  mx = a->Prec * (VpBaseFig() + 1);
1743
1748
 
1744
- n = GetPositiveInt(nFig) + VpDblFig() + BASE_FIG;
1749
+ n = GetPrecisionInt(nFig) + VpDblFig() + BASE_FIG;
1745
1750
  if (mx <= n) mx = n;
1746
1751
  GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
1747
1752
  VpSqrt(c, a);
@@ -2011,34 +2016,35 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
2011
2016
  *
2012
2017
  * Examples:
2013
2018
  *
2014
- * BigDecimal.new('-123.45678901234567890').to_s('5F')
2019
+ * BigDecimal('-123.45678901234567890').to_s('5F')
2015
2020
  * #=> '-123.45678 90123 45678 9'
2016
2021
  *
2017
- * BigDecimal.new('123.45678901234567890').to_s('+8F')
2022
+ * BigDecimal('123.45678901234567890').to_s('+8F')
2018
2023
  * #=> '+123.45678901 23456789'
2019
2024
  *
2020
- * BigDecimal.new('123.45678901234567890').to_s(' F')
2025
+ * BigDecimal('123.45678901234567890').to_s(' F')
2021
2026
  * #=> ' 123.4567890123456789'
2022
2027
  */
2023
2028
  static VALUE
2024
2029
  BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
2025
2030
  {
2026
2031
  ENTER(5);
2027
- int fmt = 0; /* 0:E format */
2028
- int fPlus = 0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
2032
+ int fmt = 0; /* 0: E format, 1: F format */
2033
+ int fPlus = 0; /* 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
2029
2034
  Real *vp;
2030
2035
  volatile VALUE str;
2031
2036
  char *psz;
2032
2037
  char ch;
2033
2038
  size_t nc, mc = 0;
2039
+ SIGNED_VALUE m;
2034
2040
  VALUE f;
2035
2041
 
2036
2042
  GUARD_OBJ(vp, GetVpValue(self, 1));
2037
2043
 
2038
2044
  if (rb_scan_args(argc, argv, "01", &f) == 1) {
2039
2045
  if (RB_TYPE_P(f, T_STRING)) {
2040
- SafeStringValue(f);
2041
- psz = RSTRING_PTR(f);
2046
+ psz = StringValueCStr(f);
2047
+ rb_check_safe_obj(f);
2042
2048
  if (*psz == ' ') {
2043
2049
  fPlus = 1;
2044
2050
  psz++;
@@ -2061,7 +2067,11 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
2061
2067
  }
2062
2068
  }
2063
2069
  else {
2064
- mc = (size_t)GetPositiveInt(f);
2070
+ m = NUM2INT(f);
2071
+ if (m <= 0) {
2072
+ rb_raise(rb_eArgError, "argument must be positive");
2073
+ }
2074
+ mc = (size_t)m;
2065
2075
  }
2066
2076
  }
2067
2077
  if (fmt) {
@@ -2158,7 +2168,7 @@ BigDecimal_exponent(VALUE self)
2158
2168
  /* Returns debugging information about the value as a string of comma-separated
2159
2169
  * values in angle brackets with a leading #:
2160
2170
  *
2161
- * BigDecimal.new("1234.5678").inspect
2171
+ * BigDecimal("1234.5678").inspect
2162
2172
  * #=> "0.12345678e4"
2163
2173
  *
2164
2174
  * The first part is the address, the second is the value as a string, and
@@ -2589,6 +2599,13 @@ static Real *BigDecimal_new(int argc, VALUE *argv);
2589
2599
  * ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
2590
2600
  * value is omitted, this exception is raised.
2591
2601
  */
2602
+ static VALUE
2603
+ BigDecimal_s_new(int argc, VALUE *argv, VALUE self)
2604
+ {
2605
+ rb_warning("BigDecimal.new is deprecated");
2606
+ return rb_call_super(argc, argv);
2607
+ }
2608
+
2592
2609
  static VALUE
2593
2610
  BigDecimal_initialize(int argc, VALUE *argv, VALUE self)
2594
2611
  {
@@ -2625,6 +2642,20 @@ BigDecimal_initialize_copy(VALUE self, VALUE other)
2625
2642
  return self;
2626
2643
  }
2627
2644
 
2645
+ static VALUE
2646
+ BigDecimal_clone(VALUE self)
2647
+ {
2648
+ rb_warning("BigDecimal#clone is deprecated.");
2649
+ return rb_call_super(0, NULL);
2650
+ }
2651
+
2652
+ static VALUE
2653
+ BigDecimal_dup(VALUE self)
2654
+ {
2655
+ rb_warning("BigDecimal#dup is deprecated.");
2656
+ return rb_call_super(0, NULL);
2657
+ }
2658
+
2628
2659
  static Real *
2629
2660
  BigDecimal_new(int argc, VALUE *argv)
2630
2661
  {
@@ -2637,7 +2668,7 @@ BigDecimal_new(int argc, VALUE *argv)
2637
2668
  mf = 0;
2638
2669
  }
2639
2670
  else {
2640
- mf = GetPositiveInt(nFig);
2671
+ mf = GetPrecisionInt(nFig);
2641
2672
  }
2642
2673
 
2643
2674
  switch (TYPE(iniValue)) {
@@ -2757,9 +2788,9 @@ BigDecimal_sign(VALUE self)
2757
2788
  * BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
2758
2789
  * BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
2759
2790
  *
2760
- * BigDecimal.new(BigDecimal('Infinity'))
2761
- * BigDecimal.new(BigDecimal('-Infinity'))
2762
- * BigDecimal(BigDecimal.new('NaN'))
2791
+ * BigDecimal(BigDecimal('Infinity'))
2792
+ * BigDecimal(BigDecimal('-Infinity'))
2793
+ * BigDecimal(BigDecimal('NaN'))
2763
2794
  * end
2764
2795
  *
2765
2796
  * For use with the BigDecimal::EXCEPTION_*
@@ -3146,15 +3177,15 @@ get_vp_value:
3146
3177
  *
3147
3178
  * require 'bigdecimal'
3148
3179
  *
3149
- * sum = BigDecimal.new("0")
3180
+ * sum = BigDecimal("0")
3150
3181
  * 10_000.times do
3151
- * sum = sum + BigDecimal.new("0.0001")
3182
+ * sum = sum + BigDecimal("0.0001")
3152
3183
  * end
3153
3184
  * print sum #=> 0.1E1
3154
3185
  *
3155
3186
  * Similarly:
3156
3187
  *
3157
- * (BigDecimal.new("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true
3188
+ * (BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true
3158
3189
  *
3159
3190
  * (1.2 - 1.0) == 0.2 #=> false
3160
3191
  *
@@ -3168,8 +3199,8 @@ get_vp_value:
3168
3199
  * BigDecimal sometimes needs to return infinity, for example if you divide
3169
3200
  * a value by zero.
3170
3201
  *
3171
- * BigDecimal.new("1.0") / BigDecimal.new("0.0") #=> Infinity
3172
- * BigDecimal.new("-1.0") / BigDecimal.new("0.0") #=> -Infinity
3202
+ * BigDecimal("1.0") / BigDecimal("0.0") #=> Infinity
3203
+ * BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity
3173
3204
  *
3174
3205
  * You can represent infinite numbers to BigDecimal using the strings
3175
3206
  * <code>'Infinity'</code>, <code>'+Infinity'</code> and
@@ -3182,13 +3213,13 @@ get_vp_value:
3182
3213
  *
3183
3214
  * Example:
3184
3215
  *
3185
- * BigDecimal.new("0.0") / BigDecimal.new("0.0") #=> NaN
3216
+ * BigDecimal("0.0") / BigDecimal("0.0") #=> NaN
3186
3217
  *
3187
3218
  * You can also create undefined values.
3188
3219
  *
3189
3220
  * NaN is never considered to be the same as any other value, even NaN itself:
3190
3221
  *
3191
- * n = BigDecimal.new('NaN')
3222
+ * n = BigDecimal('NaN')
3192
3223
  * n == 0.0 #=> false
3193
3224
  * n == n #=> false
3194
3225
  *
@@ -3201,11 +3232,11 @@ get_vp_value:
3201
3232
  * If the value which is too small to be represented is negative, a BigDecimal
3202
3233
  * value of negative zero is returned.
3203
3234
  *
3204
- * BigDecimal.new("1.0") / BigDecimal.new("-Infinity") #=> -0.0
3235
+ * BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0
3205
3236
  *
3206
3237
  * If the value is positive, a value of positive zero is returned.
3207
3238
  *
3208
- * BigDecimal.new("1.0") / BigDecimal.new("Infinity") #=> 0.0
3239
+ * BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0
3209
3240
  *
3210
3241
  * (See BigDecimal.mode for how to specify limits of precision.)
3211
3242
  *
@@ -3260,6 +3291,7 @@ Init_bigdecimal(void)
3260
3291
  rb_define_global_function("BigDecimal", BigDecimal_global_new, -1);
3261
3292
 
3262
3293
  /* Class methods */
3294
+ rb_define_singleton_method(rb_cBigDecimal, "new", BigDecimal_s_new, -1);
3263
3295
  rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
3264
3296
  rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
3265
3297
  rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
@@ -3272,6 +3304,14 @@ Init_bigdecimal(void)
3272
3304
 
3273
3305
  /* Constants definition */
3274
3306
 
3307
+ #ifndef RUBY_BIGDECIMAL_VERSION
3308
+ # error RUBY_BIGDECIMAL_VERSION is not defined
3309
+ #endif
3310
+ /*
3311
+ * The version of bigdecimal library
3312
+ */
3313
+ rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(RUBY_BIGDECIMAL_VERSION));
3314
+
3275
3315
  /*
3276
3316
  * Base value used in internal calculations. On a 32 bit system, BASE
3277
3317
  * is 10000, indicating that calculation is done in groups of 4 digits.
@@ -3408,7 +3448,8 @@ Init_bigdecimal(void)
3408
3448
  rb_define_method(rb_cBigDecimal, "modulo", BigDecimal_mod, 1);
3409
3449
  rb_define_method(rb_cBigDecimal, "remainder", BigDecimal_remainder, 1);
3410
3450
  rb_define_method(rb_cBigDecimal, "divmod", BigDecimal_divmod, 1);
3411
- /* rb_define_method(rb_cBigDecimal, "dup", BigDecimal_dup, 0); */
3451
+ rb_define_method(rb_cBigDecimal, "clone", BigDecimal_clone, 0);
3452
+ rb_define_method(rb_cBigDecimal, "dup", BigDecimal_dup, 0);
3412
3453
  rb_define_method(rb_cBigDecimal, "to_f", BigDecimal_to_f, 0);
3413
3454
  rb_define_method(rb_cBigDecimal, "abs", BigDecimal_abs, 0);
3414
3455
  rb_define_method(rb_cBigDecimal, "sqrt", BigDecimal_sqrt, 1);
@@ -5347,7 +5388,7 @@ VpSzMantissa(Real *a,char *psz)
5347
5388
 
5348
5389
  VP_EXPORT int
5349
5390
  VpToSpecialString(Real *a,char *psz,int fPlus)
5350
- /* fPlus =0:default, =1: set ' ' before digits , =2: set '+' before digits. */
5391
+ /* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
5351
5392
  {
5352
5393
  if (VpIsNaN(a)) {
5353
5394
  sprintf(psz,SZ_NaN);
@@ -5382,7 +5423,7 @@ VpToSpecialString(Real *a,char *psz,int fPlus)
5382
5423
 
5383
5424
  VP_EXPORT void
5384
5425
  VpToString(Real *a, char *psz, size_t fFmt, int fPlus)
5385
- /* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
5426
+ /* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
5386
5427
  {
5387
5428
  size_t i, n, ZeroSup;
5388
5429
  BDIGIT shift, m, e, nn;
@@ -5430,7 +5471,7 @@ VpToString(Real *a, char *psz, size_t fFmt, int fPlus)
5430
5471
 
5431
5472
  VP_EXPORT void
5432
5473
  VpToFString(Real *a, char *psz, size_t fFmt, int fPlus)
5433
- /* fPlus =0:default,=1: set ' ' before digits ,set '+' before digits. */
5474
+ /* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
5434
5475
  {
5435
5476
  size_t i, n;
5436
5477
  BDIGIT m, e, nn;
@@ -142,6 +142,12 @@ rb_sym2str(VALUE sym)
142
142
  }
143
143
  #endif
144
144
 
145
+ #ifndef ST2FIX
146
+ # undef RB_ST2FIX
147
+ # define RB_ST2FIX(h) LONG2FIX((long)(h))
148
+ # define ST2FIX(h) RB_ST2FIX(h)
149
+ #endif
150
+
145
151
  #ifdef vabs
146
152
  # undef vabs
147
153
  #endif
@@ -1,6 +1,22 @@
1
1
  # frozen_string_literal: false
2
2
  require 'mkmf'
3
3
 
4
+ case
5
+ when File.file?(File.expand_path('../bigdecimal.gemspec', __FILE__))
6
+ gemspec_path = File.expand_path('../bigdecimal.gemspec', __FILE__)
7
+ when File.file?(File.expand_path('../../../bigdecimal.gemspec', __FILE__))
8
+ gemspec_path = File.expand_path('../../../bigdecimal.gemspec', __FILE__)
9
+ else
10
+ $stderr.puts "Unable to find bigdecimal.gemspec"
11
+ abort
12
+ end
13
+
14
+ bigdecimal_version =
15
+ IO.readlines(gemspec_path)
16
+ .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([\d\.]+)\'/, 1]
17
+
18
+ $defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
19
+
4
20
  alias __have_macro__ have_macro
5
21
 
6
22
  have_func("labs", "stdlib.h")
@@ -37,7 +37,7 @@ module BigMath
37
37
  # Computes the square root of +decimal+ to the specified number of digits of
38
38
  # precision, +numeric+.
39
39
  #
40
- # BigMath.sqrt(BigDecimal.new('2'), 16).to_s
40
+ # BigMath.sqrt(BigDecimal('2'), 16).to_s
41
41
  # #=> "0.1414213562373095048801688724e1"
42
42
  #
43
43
  def sqrt(x, prec)
@@ -140,7 +140,7 @@ module BigMath
140
140
  #
141
141
  # If +decimal+ is NaN, returns NaN.
142
142
  #
143
- # BigMath.atan(BigDecimal.new('-1'), 16).to_s
143
+ # BigMath.atan(BigDecimal('-1'), 16).to_s
144
144
  # #=> "-0.785398163397448309615660845819878471907514682065e0"
145
145
  #
146
146
  def atan(x, prec)
@@ -83,7 +83,7 @@ class BigDecimal < Numeric
83
83
  #
84
84
  # require 'bigdecimal/util'
85
85
  #
86
- # d = BigDecimal.new("3.14")
86
+ # d = BigDecimal("3.14")
87
87
  # d.to_digits # => "3.14"
88
88
  #
89
89
  def to_digits
@@ -103,7 +103,7 @@ class BigDecimal < Numeric
103
103
  #
104
104
  # require 'bigdecimal/util'
105
105
  #
106
- # d = BigDecimal.new("3.14")
106
+ # d = BigDecimal("3.14")
107
107
  # d.to_d # => 0.314e1
108
108
  #
109
109
  def to_d
@@ -28,8 +28,8 @@ def rd_order(na)
28
28
  end
29
29
 
30
30
  na = ARGV.size
31
- zero = BigDecimal.new("0.0")
32
- one = BigDecimal.new("1.0")
31
+ zero = BigDecimal("0.0")
32
+ one = BigDecimal("1.0")
33
33
 
34
34
  while (n=rd_order(na))>0
35
35
  a = []
@@ -37,27 +37,28 @@ while (n=rd_order(na))>0
37
37
  b = []
38
38
  if na <= 0
39
39
  # Read data from console.
40
- printf("\nEnter coefficient matrix element A[i,j]\n");
40
+ printf("\nEnter coefficient matrix element A[i,j]\n")
41
41
  for i in 0...n do
42
42
  for j in 0...n do
43
43
  printf("A[%d,%d]? ",i,j); s = ARGF.gets
44
- a << BigDecimal.new(s);
45
- as << BigDecimal.new(s);
44
+ a << BigDecimal(s)
45
+ as << BigDecimal(s)
46
46
  end
47
- printf("Contatant vector element b[%d] ? ",i); b << BigDecimal.new(ARGF.gets);
47
+ printf("Contatant vector element b[%d] ? ",i)
48
+ b << BigDecimal(ARGF.gets)
48
49
  end
49
50
  else
50
51
  # Read data from specified file.
51
- printf("Coefficient matrix and constant vector.\n");
52
+ printf("Coefficient matrix and constant vector.\n")
52
53
  for i in 0...n do
53
54
  s = ARGF.gets
54
55
  printf("%d) %s",i,s)
55
56
  s = s.split
56
57
  for j in 0...n do
57
- a << BigDecimal.new(s[j]);
58
- as << BigDecimal.new(s[j]);
58
+ a << BigDecimal(s[j])
59
+ as << BigDecimal(s[j])
59
60
  end
60
- b << BigDecimal.new(s[n]);
61
+ b << BigDecimal(s[n])
61
62
  end
62
63
  end
63
64
  x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
@@ -12,11 +12,11 @@ include Newton
12
12
 
13
13
  class Function # :nodoc: all
14
14
  def initialize()
15
- @zero = BigDecimal.new("0.0")
16
- @one = BigDecimal.new("1.0")
17
- @two = BigDecimal.new("2.0")
18
- @ten = BigDecimal.new("10.0")
19
- @eps = BigDecimal.new("1.0e-16")
15
+ @zero = BigDecimal("0.0")
16
+ @one = BigDecimal("1.0")
17
+ @two = BigDecimal("2.0")
18
+ @ten = BigDecimal("10.0")
19
+ @eps = BigDecimal("1.0e-16")
20
20
  end
21
21
  def zero;@zero;end
22
22
  def one ;@one ;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: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-13 00:00:00.000000000 Z
13
+ date: 2017-12-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -30,16 +30,30 @@ dependencies:
30
30
  name: rake-compiler
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0.9'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
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
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: minitest
45
59
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
124
  version: '0'
111
125
  requirements: []
112
126
  rubyforge_project:
113
- rubygems_version: 2.6.8
127
+ rubygems_version: 2.6.14
114
128
  signing_key:
115
129
  specification_version: 4
116
130
  summary: Arbitrary-precision decimal floating-point number library.