bigdecimal 1.2.5 → 1.2.6
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.
- data/bigdecimal.c +101 -73
- data/bigdecimal.gemspec +1 -1
- data/bigdecimal.h +2 -2
- data/depend +13 -1
- data/lib/bigdecimal/math.rb +1 -1
- metadata +12 -10
- checksums.yaml +0 -7
data/bigdecimal.c
CHANGED
@@ -72,9 +72,9 @@ static ID id_eq;
|
|
72
72
|
|
73
73
|
/* MACRO's to guard objects from GC by keeping them in stack */
|
74
74
|
#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
|
75
|
-
#define PUSH(x) vStack[iStack++] = (VALUE)(x)
|
76
|
-
#define SAVE(p) PUSH(p->obj)
|
77
|
-
#define GUARD_OBJ(p,y)
|
75
|
+
#define PUSH(x) (vStack[iStack++] = (VALUE)(x))
|
76
|
+
#define SAVE(p) PUSH((p)->obj)
|
77
|
+
#define GUARD_OBJ(p,y) ((p)=(y), SAVE(p))
|
78
78
|
|
79
79
|
#define BASE_FIG RMPD_COMPONENT_FIGURES
|
80
80
|
#define BASE RMPD_BASE
|
@@ -86,13 +86,9 @@ static ID id_eq;
|
|
86
86
|
#define DBLE_FIG (DBL_DIG+1) /* figure of double */
|
87
87
|
#endif
|
88
88
|
|
89
|
-
#ifndef RBIGNUM_ZERO_P
|
90
|
-
# define RBIGNUM_ZERO_P(x) rb_bigzero_p(x)
|
91
|
-
#endif
|
92
|
-
|
93
89
|
#ifndef RRATIONAL_ZERO_P
|
94
|
-
# define RRATIONAL_ZERO_P(x) (FIXNUM_P(
|
95
|
-
FIX2LONG(
|
90
|
+
# define RRATIONAL_ZERO_P(x) (FIXNUM_P(rb_rational_num(x)) && \
|
91
|
+
FIX2LONG(rb_rational_num(x)) == 0)
|
96
92
|
#endif
|
97
93
|
|
98
94
|
#ifndef RRATIONAL_NEGATIVE_P
|
@@ -166,7 +162,7 @@ static const rb_data_type_t BigDecimal_data_type = {
|
|
166
162
|
"BigDecimal",
|
167
163
|
{ 0, BigDecimal_delete, BigDecimal_memsize, },
|
168
164
|
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
169
|
-
|
165
|
+
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
170
166
|
#endif
|
171
167
|
};
|
172
168
|
|
@@ -239,11 +235,11 @@ again:
|
|
239
235
|
if (prec < 0) goto unable_to_coerce_without_prec;
|
240
236
|
|
241
237
|
if (orig == Qundef ? (orig = v, 1) : orig != v) {
|
242
|
-
num =
|
238
|
+
num = rb_rational_num(v);
|
243
239
|
pv = GetVpValueWithPrec(num, -1, must);
|
244
240
|
if (pv == NULL) goto SomeOneMayDoIt;
|
245
241
|
|
246
|
-
v = BigDecimal_div2(ToValue(pv),
|
242
|
+
v = BigDecimal_div2(ToValue(pv), rb_rational_den(v), LONG2NUM(prec));
|
247
243
|
goto again;
|
248
244
|
}
|
249
245
|
|
@@ -366,9 +362,9 @@ BigDecimal_hash(VALUE self)
|
|
366
362
|
* Method used to provide marshalling support.
|
367
363
|
*
|
368
364
|
* inf = BigDecimal.new('Infinity')
|
369
|
-
*
|
365
|
+
* #=> #<BigDecimal:1e16fa8,'Infinity',9(9)>
|
370
366
|
* BigDecimal._load(inf._dump)
|
371
|
-
*
|
367
|
+
* #=> #<BigDecimal:1df8dc8,'Infinity',9(9)>
|
372
368
|
*
|
373
369
|
* See the Marshal module.
|
374
370
|
*/
|
@@ -617,7 +613,7 @@ VpCopy(Real *pv, Real const* const x)
|
|
617
613
|
return pv;
|
618
614
|
}
|
619
615
|
|
620
|
-
/* Returns True if the value is Not a Number */
|
616
|
+
/* Returns True if the value is Not a Number. */
|
621
617
|
static VALUE
|
622
618
|
BigDecimal_IsNaN(VALUE self)
|
623
619
|
{
|
@@ -638,7 +634,7 @@ BigDecimal_IsInfinite(VALUE self)
|
|
638
634
|
return Qnil;
|
639
635
|
}
|
640
636
|
|
641
|
-
/* Returns True if the value is finite (not NaN or infinite) */
|
637
|
+
/* Returns True if the value is finite (not NaN or infinite). */
|
642
638
|
static VALUE
|
643
639
|
BigDecimal_IsFinite(VALUE self)
|
644
640
|
{
|
@@ -802,8 +798,8 @@ BigDecimal_to_r(VALUE self)
|
|
802
798
|
* be coerced into a BigDecimal value.
|
803
799
|
*
|
804
800
|
* e.g.
|
805
|
-
*
|
806
|
-
*
|
801
|
+
* a = BigDecimal.new("1.0")
|
802
|
+
* b = a / 2.0 #=> 0.5
|
807
803
|
*
|
808
804
|
* Note that coercing a String to a BigDecimal is not supported by default;
|
809
805
|
* it requires a special compile-time option when building Ruby.
|
@@ -861,8 +857,8 @@ BigDecimal_uplus(VALUE self)
|
|
861
857
|
* c = a + b
|
862
858
|
*
|
863
859
|
* digits:: If specified and less than the number of significant digits of the
|
864
|
-
*
|
865
|
-
* BigDecimal.mode.
|
860
|
+
* result, the result is rounded to that number of digits, according
|
861
|
+
* to BigDecimal.mode.
|
866
862
|
*/
|
867
863
|
static VALUE
|
868
864
|
BigDecimal_add(VALUE self, VALUE r)
|
@@ -906,7 +902,7 @@ BigDecimal_add(VALUE self, VALUE r)
|
|
906
902
|
}
|
907
903
|
|
908
904
|
/* call-seq:
|
909
|
-
*
|
905
|
+
* a - b -> bigdecimal
|
910
906
|
*
|
911
907
|
* Subtract the specified value.
|
912
908
|
*
|
@@ -1090,7 +1086,7 @@ BigDecimal_comp(VALUE self, VALUE r)
|
|
1090
1086
|
*
|
1091
1087
|
* Values may be coerced to perform the comparison:
|
1092
1088
|
*
|
1093
|
-
*
|
1089
|
+
* BigDecimal.new('1.0') == 1.0 -> true
|
1094
1090
|
*/
|
1095
1091
|
static VALUE
|
1096
1092
|
BigDecimal_eq(VALUE self, VALUE r)
|
@@ -1182,8 +1178,8 @@ BigDecimal_neg(VALUE self)
|
|
1182
1178
|
* c = a * b
|
1183
1179
|
*
|
1184
1180
|
* digits:: If specified and less than the number of significant digits of the
|
1185
|
-
*
|
1186
|
-
* BigDecimal.mode.
|
1181
|
+
* result, the result is rounded to that number of digits, according
|
1182
|
+
* to BigDecimal.mode.
|
1187
1183
|
*/
|
1188
1184
|
static VALUE
|
1189
1185
|
BigDecimal_mult(VALUE self, VALUE r)
|
@@ -1256,8 +1252,8 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
|
|
1256
1252
|
* c = a.div(b,n)
|
1257
1253
|
*
|
1258
1254
|
* digits:: If specified and less than the number of significant digits of the
|
1259
|
-
*
|
1260
|
-
* BigDecimal.mode.
|
1255
|
+
* result, the result is rounded to that number of digits, according
|
1256
|
+
* to BigDecimal.mode.
|
1261
1257
|
*
|
1262
1258
|
* If digits is 0, the result is the same as the / operator. If not, the
|
1263
1259
|
* result is an integer BigDecimal, by analogy with Float#div.
|
@@ -1436,7 +1432,10 @@ BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
|
|
1436
1432
|
return Qnil;
|
1437
1433
|
}
|
1438
1434
|
|
1439
|
-
/*
|
1435
|
+
/* call-seq:
|
1436
|
+
* remainder(value)
|
1437
|
+
*
|
1438
|
+
* Returns the remainder from dividing by the value.
|
1440
1439
|
*
|
1441
1440
|
* x.remainder(y) means x-y*(x/y).truncate
|
1442
1441
|
*/
|
@@ -1450,21 +1449,24 @@ BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
|
|
1450
1449
|
return ToValue(rv);
|
1451
1450
|
}
|
1452
1451
|
|
1453
|
-
/*
|
1452
|
+
/* call-seq:
|
1453
|
+
* divmod(value)
|
1454
|
+
*
|
1455
|
+
* Divides by the specified value, and returns the quotient and modulus
|
1454
1456
|
* as BigDecimal numbers. The quotient is rounded towards negative infinity.
|
1455
1457
|
*
|
1456
1458
|
* For example:
|
1457
1459
|
*
|
1458
|
-
*
|
1460
|
+
* require 'bigdecimal'
|
1459
1461
|
*
|
1460
|
-
*
|
1461
|
-
*
|
1462
|
+
* a = BigDecimal.new("42")
|
1463
|
+
* b = BigDecimal.new("9")
|
1462
1464
|
*
|
1463
|
-
*
|
1465
|
+
* q, m = a.divmod(b)
|
1464
1466
|
*
|
1465
|
-
*
|
1467
|
+
* c = q * b + m
|
1466
1468
|
*
|
1467
|
-
*
|
1469
|
+
* a == c #=> true
|
1468
1470
|
*
|
1469
1471
|
* The quotient q is (a/b).floor, and the modulus is the amount that must be
|
1470
1472
|
* added to q * b to get a.
|
@@ -1551,7 +1553,7 @@ BigDecimal_add2(VALUE self, VALUE b, VALUE n)
|
|
1551
1553
|
}
|
1552
1554
|
}
|
1553
1555
|
|
1554
|
-
/*
|
1556
|
+
/* call-seq:
|
1555
1557
|
* sub(value, digits) -> bigdecimal
|
1556
1558
|
*
|
1557
1559
|
* Subtract the specified value.
|
@@ -1560,8 +1562,8 @@ BigDecimal_add2(VALUE self, VALUE b, VALUE n)
|
|
1560
1562
|
* c = a.sub(b,n)
|
1561
1563
|
*
|
1562
1564
|
* digits:: If specified and less than the number of significant digits of the
|
1563
|
-
*
|
1564
|
-
* BigDecimal.mode.
|
1565
|
+
* result, the result is rounded to that number of digits, according
|
1566
|
+
* to BigDecimal.mode.
|
1565
1567
|
*
|
1566
1568
|
*/
|
1567
1569
|
static VALUE
|
@@ -1599,11 +1601,10 @@ BigDecimal_mult2(VALUE self, VALUE b, VALUE n)
|
|
1599
1601
|
}
|
1600
1602
|
}
|
1601
1603
|
|
1602
|
-
/* Returns the absolute value.
|
1604
|
+
/* Returns the absolute value, as a BigDecimal.
|
1603
1605
|
*
|
1604
|
-
*
|
1605
|
-
*
|
1606
|
-
* BigDecimal('-3').abs -> 3
|
1606
|
+
* BigDecimal('5').abs #=> 5
|
1607
|
+
* BigDecimal('-3').abs #=> 3
|
1607
1608
|
*/
|
1608
1609
|
static VALUE
|
1609
1610
|
BigDecimal_abs(VALUE self)
|
@@ -1644,7 +1645,7 @@ BigDecimal_sqrt(VALUE self, VALUE nFig)
|
|
1644
1645
|
return ToValue(c);
|
1645
1646
|
}
|
1646
1647
|
|
1647
|
-
/* Return the integer part of the number.
|
1648
|
+
/* Return the integer part of the number, as a BigDecimal.
|
1648
1649
|
*/
|
1649
1650
|
static VALUE
|
1650
1651
|
BigDecimal_fix(VALUE self)
|
@@ -1663,10 +1664,12 @@ BigDecimal_fix(VALUE self)
|
|
1663
1664
|
/* call-seq:
|
1664
1665
|
* round(n, mode)
|
1665
1666
|
*
|
1666
|
-
* Round to the nearest
|
1667
|
+
* Round to the nearest integer (by default), returning the result as a
|
1668
|
+
* BigDecimal.
|
1667
1669
|
*
|
1668
1670
|
* BigDecimal('3.14159').round #=> 3
|
1669
1671
|
* BigDecimal('8.7').round #=> 9
|
1672
|
+
* BigDecimal('-9.9').round #=> -10
|
1670
1673
|
*
|
1671
1674
|
* If n is specified and positive, the fractional part of the result has no
|
1672
1675
|
* more than that many digits.
|
@@ -1724,10 +1727,12 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self)
|
|
1724
1727
|
/* call-seq:
|
1725
1728
|
* truncate(n)
|
1726
1729
|
*
|
1727
|
-
* Truncate to the nearest
|
1730
|
+
* Truncate to the nearest integer (by default), returning the result as a
|
1731
|
+
* BigDecimal.
|
1728
1732
|
*
|
1729
1733
|
* BigDecimal('3.14159').truncate #=> 3
|
1730
1734
|
* BigDecimal('8.7').truncate #=> 8
|
1735
|
+
* BigDecimal('-9.9').truncate #=> -9
|
1731
1736
|
*
|
1732
1737
|
* If n is specified and positive, the fractional part of the result has no
|
1733
1738
|
* more than that many digits.
|
@@ -1766,7 +1771,7 @@ BigDecimal_truncate(int argc, VALUE *argv, VALUE self)
|
|
1766
1771
|
return ToValue(c);
|
1767
1772
|
}
|
1768
1773
|
|
1769
|
-
/* Return the fractional part of the number.
|
1774
|
+
/* Return the fractional part of the number, as a BigDecimal.
|
1770
1775
|
*/
|
1771
1776
|
static VALUE
|
1772
1777
|
BigDecimal_frac(VALUE self)
|
@@ -1898,14 +1903,14 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
|
|
1898
1903
|
*
|
1899
1904
|
* Examples:
|
1900
1905
|
*
|
1901
|
-
*
|
1902
|
-
*
|
1906
|
+
* BigDecimal.new('-123.45678901234567890').to_s('5F')
|
1907
|
+
* #=> '-123.45678 90123 45678 9'
|
1903
1908
|
*
|
1904
|
-
*
|
1905
|
-
*
|
1909
|
+
* BigDecimal.new('123.45678901234567890').to_s('+8F')
|
1910
|
+
* #=> '+123.45678901 23456789'
|
1906
1911
|
*
|
1907
|
-
*
|
1908
|
-
*
|
1912
|
+
* BigDecimal.new('123.45678901234567890').to_s(' F')
|
1913
|
+
* #=> ' 123.4567890123456789'
|
1909
1914
|
*/
|
1910
1915
|
static VALUE
|
1911
1916
|
BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
|
@@ -2045,8 +2050,8 @@ BigDecimal_exponent(VALUE self)
|
|
2045
2050
|
/* Returns debugging information about the value as a string of comma-separated
|
2046
2051
|
* values in angle brackets with a leading #:
|
2047
2052
|
*
|
2048
|
-
*
|
2049
|
-
* "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
|
2053
|
+
* BigDecimal.new("1234.5678").inspect
|
2054
|
+
* #=> "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
|
2050
2055
|
*
|
2051
2056
|
* The first part is the address, the second is the value as a string, and
|
2052
2057
|
* the final part ss(mm) is the current number of significant digits and the
|
@@ -2095,7 +2100,7 @@ is_negative(VALUE x)
|
|
2095
2100
|
return FIX2LONG(x) < 0;
|
2096
2101
|
}
|
2097
2102
|
else if (RB_TYPE_P(x, T_BIGNUM)) {
|
2098
|
-
return
|
2103
|
+
return FIX2INT(rb_big_cmp(x, INT2FIX(0))) < 0;
|
2099
2104
|
}
|
2100
2105
|
else if (RB_TYPE_P(x, T_FLOAT)) {
|
2101
2106
|
return RFLOAT_VALUE(x) < 0.0;
|
@@ -2118,7 +2123,7 @@ is_zero(VALUE x)
|
|
2118
2123
|
return Qfalse;
|
2119
2124
|
|
2120
2125
|
case T_RATIONAL:
|
2121
|
-
num =
|
2126
|
+
num = rb_rational_num(x);
|
2122
2127
|
return FIXNUM_P(num) && FIX2LONG(num) == 0;
|
2123
2128
|
|
2124
2129
|
default:
|
@@ -2141,8 +2146,8 @@ is_one(VALUE x)
|
|
2141
2146
|
return Qfalse;
|
2142
2147
|
|
2143
2148
|
case T_RATIONAL:
|
2144
|
-
num =
|
2145
|
-
den =
|
2149
|
+
num = rb_rational_num(x);
|
2150
|
+
den = rb_rational_den(x);
|
2146
2151
|
return FIXNUM_P(den) && FIX2LONG(den) == 1 &&
|
2147
2152
|
FIXNUM_P(num) && FIX2LONG(num) == 1;
|
2148
2153
|
|
@@ -2200,7 +2205,7 @@ rmpd_power_by_big_decimal(Real const* x, Real const* exp, ssize_t const n)
|
|
2200
2205
|
*
|
2201
2206
|
* Note that n must be an Integer.
|
2202
2207
|
*
|
2203
|
-
* Also available as the operator
|
2208
|
+
* Also available as the operator **.
|
2204
2209
|
*/
|
2205
2210
|
static VALUE
|
2206
2211
|
BigDecimal_power(int argc, VALUE*argv, VALUE self)
|
@@ -2248,14 +2253,14 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self)
|
|
2248
2253
|
break;
|
2249
2254
|
|
2250
2255
|
case T_RATIONAL:
|
2251
|
-
if (is_zero(
|
2256
|
+
if (is_zero(rb_rational_num(vexp))) {
|
2252
2257
|
if (is_positive(vexp)) {
|
2253
2258
|
vexp = INT2FIX(0);
|
2254
2259
|
goto retry;
|
2255
2260
|
}
|
2256
2261
|
}
|
2257
|
-
else if (is_one(
|
2258
|
-
vexp =
|
2262
|
+
else if (is_one(rb_rational_den(vexp))) {
|
2263
|
+
vexp = rb_rational_num(vexp);
|
2259
2264
|
goto retry;
|
2260
2265
|
}
|
2261
2266
|
exp = GetVpValueWithPrec(vexp, n, 1);
|
@@ -2432,9 +2437,11 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self)
|
|
2432
2437
|
}
|
2433
2438
|
|
2434
2439
|
/* call-seq:
|
2435
|
-
*
|
2440
|
+
* a ** n -> bigdecimal
|
2441
|
+
*
|
2442
|
+
* Returns the value raised to the power of n.
|
2436
2443
|
*
|
2437
|
-
*
|
2444
|
+
* See BigDecimal#power.
|
2438
2445
|
*/
|
2439
2446
|
static VALUE
|
2440
2447
|
BigDecimal_power_op(VALUE self, VALUE exp)
|
@@ -2467,13 +2474,28 @@ static Real *BigDecimal_new(int argc, VALUE *argv);
|
|
2467
2474
|
*
|
2468
2475
|
* The actual number of significant digits used in computation is usually
|
2469
2476
|
* larger than the specified number.
|
2477
|
+
*
|
2478
|
+
* ==== Exceptions
|
2479
|
+
*
|
2480
|
+
* TypeError:: If the +initial+ type is neither Fixnum, Bignum, Float,
|
2481
|
+
* Rational, nor BigDecimal, this exception is raised.
|
2482
|
+
*
|
2483
|
+
* TypeError:: If the +digits+ is not a Fixnum, this exception is raised.
|
2484
|
+
*
|
2485
|
+
* ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than
|
2486
|
+
* Float::DIG + 1, this exception is raised.
|
2487
|
+
*
|
2488
|
+
* ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
|
2489
|
+
* value is omitted, this exception is raised.
|
2470
2490
|
*/
|
2471
2491
|
static VALUE
|
2472
2492
|
BigDecimal_initialize(int argc, VALUE *argv, VALUE self)
|
2473
2493
|
{
|
2494
|
+
ENTER(1);
|
2474
2495
|
Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
|
2475
|
-
Real *x
|
2496
|
+
Real *x;
|
2476
2497
|
|
2498
|
+
GUARD_OBJ(x, BigDecimal_new(argc, argv));
|
2477
2499
|
if (ToValue(x)) {
|
2478
2500
|
pv = VpCopy(pv, x);
|
2479
2501
|
}
|
@@ -2496,7 +2518,9 @@ BigDecimal_initialize_copy(VALUE self, VALUE other)
|
|
2496
2518
|
Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
|
2497
2519
|
Real *x = rb_check_typeddata(other, &BigDecimal_data_type);
|
2498
2520
|
|
2499
|
-
|
2521
|
+
if (self != other) {
|
2522
|
+
DATA_PTR(self) = VpCopy(pv, x);
|
2523
|
+
}
|
2500
2524
|
return self;
|
2501
2525
|
}
|
2502
2526
|
|
@@ -2552,7 +2576,10 @@ BigDecimal_new(int argc, VALUE *argv)
|
|
2552
2576
|
static VALUE
|
2553
2577
|
BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
|
2554
2578
|
{
|
2555
|
-
|
2579
|
+
ENTER(1);
|
2580
|
+
Real *pv;
|
2581
|
+
|
2582
|
+
GUARD_OBJ(pv, BigDecimal_new(argc, argv));
|
2556
2583
|
if (ToValue(pv)) pv = VpCopy(NULL, pv);
|
2557
2584
|
pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
|
2558
2585
|
return pv->obj;
|
@@ -2874,8 +2901,9 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec)
|
|
2874
2901
|
goto get_vp_value;
|
2875
2902
|
|
2876
2903
|
case T_BIGNUM:
|
2877
|
-
|
2878
|
-
|
2904
|
+
i = FIX2INT(rb_big_cmp(x, INT2FIX(0)));
|
2905
|
+
zero = i == 0;
|
2906
|
+
negative = i < 0;
|
2879
2907
|
get_vp_value:
|
2880
2908
|
if (zero || negative) break;
|
2881
2909
|
vx = GetVpValue(x, 0);
|
@@ -4825,11 +4853,11 @@ out_side:
|
|
4825
4853
|
space_error:
|
4826
4854
|
#ifdef BIGDECIMAL_DEBUG
|
4827
4855
|
if (gfDebug) {
|
4828
|
-
printf(" word_a=%
|
4829
|
-
printf(" word_b=%
|
4830
|
-
printf(" word_c=%
|
4831
|
-
printf(" word_r=%
|
4832
|
-
printf(" ind_r =%
|
4856
|
+
printf(" word_a=%"PRIuSIZE"\n", word_a);
|
4857
|
+
printf(" word_b=%"PRIuSIZE"\n", word_b);
|
4858
|
+
printf(" word_c=%"PRIuSIZE"\n", word_c);
|
4859
|
+
printf(" word_r=%"PRIuSIZE"\n", word_r);
|
4860
|
+
printf(" ind_r =%"PRIuSIZE"\n", ind_r);
|
4833
4861
|
}
|
4834
4862
|
#endif /* BIGDECIMAL_DEBUG */
|
4835
4863
|
rb_bug("ERROR(VpDivd): space for remainder too small.");
|
data/bigdecimal.gemspec
CHANGED
data/bigdecimal.h
CHANGED
@@ -291,7 +291,7 @@ VP_EXPORT Real *VpOne(void);
|
|
291
291
|
#define VpIsZero(a) (VpIsPosZero(a) || VpIsNegZero(a))
|
292
292
|
#define VpSetPosZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO)
|
293
293
|
#define VpSetNegZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO)
|
294
|
-
#define VpSetZero(a,s) (
|
294
|
+
#define VpSetZero(a,s) (void)(((s)>0)?VpSetPosZero(a):VpSetNegZero(a))
|
295
295
|
|
296
296
|
/* NaN */
|
297
297
|
#define VpIsNaN(a) ((a)->sign==VP_SIGN_NaN)
|
@@ -304,7 +304,7 @@ VP_EXPORT Real *VpOne(void);
|
|
304
304
|
#define VpIsDef(a) ( !(VpIsNaN(a)||VpIsInf(a)) )
|
305
305
|
#define VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)
|
306
306
|
#define VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)
|
307
|
-
#define VpSetInf(a,s) (
|
307
|
+
#define VpSetInf(a,s) (void)(((s)>0)?VpSetPosInf(a):VpSetNegInf(a))
|
308
308
|
#define VpHasVal(a) (a->frac[0])
|
309
309
|
#define VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))
|
310
310
|
#define VpExponent(a) (a->exponent)
|
data/depend
CHANGED
@@ -1 +1,13 @@
|
|
1
|
-
|
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/st.h
|
8
|
+
bigdecimal.o: $(hdrdir)/ruby/subst.h
|
9
|
+
bigdecimal.o: $(hdrdir)/ruby/util.h
|
10
|
+
bigdecimal.o: $(hdrdir)/ruby/ruby.h
|
11
|
+
bigdecimal.o: bigdecimal.c
|
12
|
+
bigdecimal.o: bigdecimal.h
|
13
|
+
# AUTOGENERATED DEPENDENCIES END
|
data/lib/bigdecimal/math.rb
CHANGED
@@ -180,7 +180,7 @@ module BigMath
|
|
180
180
|
# #=> "0.3141592653589793238462643388813853786957412E1"
|
181
181
|
#
|
182
182
|
def PI(prec)
|
183
|
-
raise ArgumentError, "Zero or negative
|
183
|
+
raise ArgumentError, "Zero or negative precision for PI" if prec <= 0
|
184
184
|
n = prec + BigDecimal.double_fig
|
185
185
|
zero = BigDecimal("0")
|
186
186
|
one = BigDecimal("1")
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigdecimal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Kenta Murata
|
@@ -10,7 +11,7 @@ authors:
|
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
14
15
|
dependencies: []
|
15
16
|
description: This library provides arbitrary-precision decimal floating-point number
|
16
17
|
class.
|
@@ -20,10 +21,10 @@ extensions:
|
|
20
21
|
- extconf.rb
|
21
22
|
extra_rdoc_files: []
|
22
23
|
files:
|
23
|
-
- README
|
24
|
-
- bigdecimal.c
|
25
24
|
- bigdecimal.gemspec
|
25
|
+
- bigdecimal.c
|
26
26
|
- bigdecimal.h
|
27
|
+
- README
|
27
28
|
- depend
|
28
29
|
- extconf.rb
|
29
30
|
- lib/bigdecimal/jacobian.rb
|
@@ -36,25 +37,26 @@ files:
|
|
36
37
|
- sample/pi.rb
|
37
38
|
homepage: http://www.ruby-lang.org
|
38
39
|
licenses: []
|
39
|
-
metadata: {}
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
require_paths:
|
43
|
-
-
|
43
|
+
- .
|
44
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
45
46
|
requirements:
|
46
|
-
- -
|
47
|
+
- - ! '>='
|
47
48
|
- !ruby/object:Gem::Version
|
48
49
|
version: '0'
|
49
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
50
52
|
requirements:
|
51
|
-
- -
|
53
|
+
- - ! '>='
|
52
54
|
- !ruby/object:Gem::Version
|
53
55
|
version: '0'
|
54
56
|
requirements: []
|
55
57
|
rubyforge_project:
|
56
|
-
rubygems_version:
|
58
|
+
rubygems_version: 1.8.23.2
|
57
59
|
signing_key:
|
58
|
-
specification_version:
|
60
|
+
specification_version: 3
|
59
61
|
summary: Arbitrary-precision decimal floating-point number library.
|
60
62
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 3d7c070b55ea42a8186edff5bd590ec595c3f91b
|
4
|
-
data.tar.gz: 2b387b97b4360f632e8f71d17ad69b0e3ce0d582
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: f1bd4f4b4301d592507985496a19121906d4aeb9db7e3b862595e71ef1c87d6f3ac1d69227b8a1a582ec091cd6afb51f7f54e48db53bba2447623de62cd21500
|
7
|
-
data.tar.gz: 602f15737c778167bd453b408c6fe18c411461943f73ed819de569deb8c271676a97d356aecb8d95986660cc4b917933a694ddeec1ad7c3c78ec411006adadd7
|