bigdecimal 3.1.3 → 3.1.5
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 +94 -80
- data/ext/bigdecimal/extconf.rb +0 -25
- data/lib/bigdecimal/util.rb +5 -5
- data/lib/bigdecimal.rb +5 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109c70397447eabf22f0e869db4b2c0c902c7d0baaf28865aebfc534e3c14b9f
|
4
|
+
data.tar.gz: 43df8b8d27be2b5cbf29c7396c07eabbca3119067b525f94155f2901f2c058d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b0b82714e555c1ca30e761296f497d2cf914a50d19d553cca37b51af6b85914bbc86772b5bb8d70388020dbff9abc3e0501b3d6bb95ba3d68c30a91d5b197fa
|
7
|
+
data.tar.gz: a4bc1e9d1918fb84f5405c3dc2fce2358a074f0f729084936ec7ee2010dffeeee889fb0054d932f35175c48577888fc74bba7afde492f628d8beef5deeeadc0d
|
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.5"
|
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
|
|
@@ -655,7 +657,7 @@ BigDecimal_precision(VALUE self)
|
|
655
657
|
* Returns the number of decimal digits following the decimal digits in +self+.
|
656
658
|
*
|
657
659
|
* BigDecimal("0").scale # => 0
|
658
|
-
* BigDecimal("1").scale # =>
|
660
|
+
* BigDecimal("1").scale # => 0
|
659
661
|
* BigDecimal("1.1").scale # => 1
|
660
662
|
* BigDecimal("3.1415").scale # => 4
|
661
663
|
* BigDecimal("-1e20").precision # => 0
|
@@ -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)));
|
@@ -2680,7 +2689,7 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
|
|
2680
2689
|
* A space at the start of s returns positive values with a leading space.
|
2681
2690
|
*
|
2682
2691
|
* If s contains a number, a space is inserted after each group of that many
|
2683
|
-
*
|
2692
|
+
* digits, starting from '.' and counting outwards.
|
2684
2693
|
*
|
2685
2694
|
* If s ends with an 'E', engineering notation (0.xxxxEnn) is used.
|
2686
2695
|
*
|
@@ -2688,14 +2697,14 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
|
|
2688
2697
|
*
|
2689
2698
|
* Examples:
|
2690
2699
|
*
|
2691
|
-
* BigDecimal('-
|
2692
|
-
* #=> '-123.45678 90123 45678 9'
|
2700
|
+
* BigDecimal('-1234567890123.45678901234567890').to_s('5F')
|
2701
|
+
* #=> '-123 45678 90123.45678 90123 45678 9'
|
2693
2702
|
*
|
2694
|
-
* BigDecimal('
|
2695
|
-
* #=> '+
|
2703
|
+
* BigDecimal('1234567890123.45678901234567890').to_s('+8F')
|
2704
|
+
* #=> '+12345 67890123.45678901 23456789'
|
2696
2705
|
*
|
2697
|
-
* BigDecimal('
|
2698
|
-
* #=> '
|
2706
|
+
* BigDecimal('1234567890123.45678901234567890').to_s(' F')
|
2707
|
+
* #=> ' 1234567890123.4567890123456789'
|
2699
2708
|
*/
|
2700
2709
|
static VALUE
|
2701
2710
|
BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
|
@@ -3713,7 +3722,7 @@ rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
|
|
3713
3722
|
* - Other type:
|
3714
3723
|
*
|
3715
3724
|
* - Raises an exception if keyword argument +exception+ is +true+.
|
3716
|
-
* - Returns +nil+ if keyword argument +exception+ is +
|
3725
|
+
* - Returns +nil+ if keyword argument +exception+ is +false+.
|
3717
3726
|
*
|
3718
3727
|
* Raises an exception if +value+ evaluates to a Float
|
3719
3728
|
* and +digits+ is larger than Float::DIG + 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
|
|
@@ -4347,7 +4363,20 @@ BigDecimal_negative_zero(void)
|
|
4347
4363
|
* (2/3r).to_d(3) # => 0.667e0
|
4348
4364
|
* "0.5".to_d # => 0.5e0
|
4349
4365
|
*
|
4350
|
-
* ==
|
4366
|
+
* == Methods for Working with \JSON
|
4367
|
+
*
|
4368
|
+
* - {::json_create}[https://docs.ruby-lang.org/en/master/BigDecimal.html#method-c-json_create]:
|
4369
|
+
* Returns a new \BigDecimal object constructed from the given object.
|
4370
|
+
* - {#as_json}[https://docs.ruby-lang.org/en/master/BigDecimal.html#method-i-as_json]:
|
4371
|
+
* Returns a 2-element hash representing +self+.
|
4372
|
+
* - {#to_json}[https://docs.ruby-lang.org/en/master/BigDecimal.html#method-i-to_json]:
|
4373
|
+
* Returns a \JSON string representing +self+.
|
4374
|
+
*
|
4375
|
+
* These methods are provided by the {JSON gem}[https://github.com/flori/json]. To make these methods available:
|
4376
|
+
*
|
4377
|
+
* require 'json/add/bigdecimal'
|
4378
|
+
*
|
4379
|
+
* * == License
|
4351
4380
|
*
|
4352
4381
|
* Copyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
|
4353
4382
|
*
|
@@ -4395,13 +4424,10 @@ Init_bigdecimal(void)
|
|
4395
4424
|
|
4396
4425
|
/* Constants definition */
|
4397
4426
|
|
4398
|
-
#ifndef RUBY_BIGDECIMAL_VERSION
|
4399
|
-
# error RUBY_BIGDECIMAL_VERSION is not defined
|
4400
|
-
#endif
|
4401
4427
|
/*
|
4402
4428
|
* The version of bigdecimal library
|
4403
4429
|
*/
|
4404
|
-
rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(
|
4430
|
+
rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(BIGDECIMAL_VERSION));
|
4405
4431
|
|
4406
4432
|
/*
|
4407
4433
|
* Base value used in internal calculations. On a 32 bit system, BASE
|
@@ -6453,7 +6479,7 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
|
6453
6479
|
}
|
6454
6480
|
}
|
6455
6481
|
nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a));
|
6456
|
-
nc += fprintf(fp, " (%"PRIdVALUE", %
|
6482
|
+
nc += fprintf(fp, " (%"PRIdVALUE", %"PRIuSIZE", %"PRIuSIZE")", a->exponent, a->Prec, a->MaxPrec);
|
6457
6483
|
}
|
6458
6484
|
else {
|
6459
6485
|
nc += fprintf(fp, "0.0");
|
@@ -6693,95 +6719,90 @@ VpToFString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus)
|
|
6693
6719
|
/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
|
6694
6720
|
{
|
6695
6721
|
size_t i, n;
|
6696
|
-
DECDIG m, e
|
6722
|
+
DECDIG m, e;
|
6697
6723
|
char *p = buf;
|
6698
|
-
size_t plen = buflen;
|
6724
|
+
size_t plen = buflen, delim = fFmt;
|
6699
6725
|
ssize_t ex;
|
6700
6726
|
|
6701
6727
|
if (VpToSpecialString(a, buf, buflen, fPlus)) return;
|
6702
6728
|
|
6703
|
-
#define
|
6704
|
-
if (plen <
|
6705
|
-
|
6706
|
-
|
6729
|
+
#define APPEND(c, group) do { \
|
6730
|
+
if (plen < 1) goto overflow; \
|
6731
|
+
if (group && delim == 0) { \
|
6732
|
+
*p = ' '; \
|
6733
|
+
p += 1; \
|
6734
|
+
plen -= 1; \
|
6735
|
+
} \
|
6736
|
+
if (plen < 1) goto overflow; \
|
6737
|
+
*p = c; \
|
6738
|
+
p += 1; \
|
6739
|
+
plen -= 1; \
|
6740
|
+
if (group) delim = (delim + 1) % fFmt; \
|
6707
6741
|
} while (0)
|
6708
6742
|
|
6709
6743
|
|
6710
6744
|
if (BIGDECIMAL_NEGATIVE_P(a)) {
|
6711
|
-
|
6712
|
-
ADVANCE(1);
|
6745
|
+
APPEND('-', false);
|
6713
6746
|
}
|
6714
6747
|
else if (fPlus == 1) {
|
6715
|
-
|
6716
|
-
ADVANCE(1);
|
6748
|
+
APPEND(' ', false);
|
6717
6749
|
}
|
6718
6750
|
else if (fPlus == 2) {
|
6719
|
-
|
6720
|
-
ADVANCE(1);
|
6751
|
+
APPEND('+', false);
|
6721
6752
|
}
|
6722
6753
|
|
6723
6754
|
n = a->Prec;
|
6724
6755
|
ex = a->exponent;
|
6725
6756
|
if (ex <= 0) {
|
6726
|
-
|
6727
|
-
|
6728
|
-
|
6729
|
-
|
6730
|
-
|
6731
|
-
|
6732
|
-
++ex;
|
6757
|
+
APPEND('0', false);
|
6758
|
+
APPEND('.', false);
|
6759
|
+
}
|
6760
|
+
while (ex < 0) {
|
6761
|
+
for (i=0; i < BASE_FIG; ++i) {
|
6762
|
+
APPEND('0', fFmt > 0);
|
6733
6763
|
}
|
6734
|
-
ex
|
6764
|
+
++ex;
|
6735
6765
|
}
|
6736
6766
|
|
6737
6767
|
for (i = 0; i < n; ++i) {
|
6738
|
-
|
6739
|
-
|
6740
|
-
|
6741
|
-
|
6742
|
-
ADVANCE(n);
|
6743
|
-
}
|
6744
|
-
else {
|
6745
|
-
m = BASE1;
|
6746
|
-
e = a->frac[i];
|
6747
|
-
while (m) {
|
6748
|
-
nn = e / m;
|
6749
|
-
*p = (char)(nn + '0');
|
6750
|
-
ADVANCE(1);
|
6751
|
-
e = e - nn * m;
|
6768
|
+
m = BASE1;
|
6769
|
+
e = a->frac[i];
|
6770
|
+
if (i == 0 && ex > 0) {
|
6771
|
+
for (delim = 0; e / m == 0; delim++) {
|
6752
6772
|
m /= 10;
|
6753
6773
|
}
|
6774
|
+
if (fFmt > 0) {
|
6775
|
+
delim = 2*fFmt - (ex * BASE_FIG - delim) % fFmt;
|
6776
|
+
}
|
6777
|
+
}
|
6778
|
+
while (m && (e || (i < n - 1) || ex > 0)) {
|
6779
|
+
APPEND((char)(e / m + '0'), fFmt > 0);
|
6780
|
+
e %= m;
|
6781
|
+
m /= 10;
|
6754
6782
|
}
|
6755
|
-
if (ex == 0) {
|
6756
|
-
|
6757
|
-
|
6783
|
+
if (--ex == 0) {
|
6784
|
+
APPEND('.', false);
|
6785
|
+
delim = fFmt;
|
6758
6786
|
}
|
6759
6787
|
}
|
6760
|
-
|
6761
|
-
|
6762
|
-
|
6763
|
-
|
6764
|
-
ADVANCE(1);
|
6788
|
+
|
6789
|
+
while (ex > 0) {
|
6790
|
+
for (i=0; i < BASE_FIG; ++i) {
|
6791
|
+
APPEND('0', fFmt > 0);
|
6765
6792
|
}
|
6766
|
-
if (ex == 0) {
|
6767
|
-
|
6768
|
-
ADVANCE(1);
|
6793
|
+
if (--ex == 0) {
|
6794
|
+
APPEND('.', false);
|
6769
6795
|
}
|
6770
6796
|
}
|
6771
6797
|
|
6772
6798
|
*p = '\0';
|
6773
|
-
while (p - 1 > buf && p[-1] == '0') {
|
6774
|
-
*(--p) = '\0';
|
6775
|
-
++plen;
|
6776
|
-
}
|
6777
6799
|
if (p - 1 > buf && p[-1] == '.') {
|
6778
6800
|
snprintf(p, plen, "0");
|
6779
6801
|
}
|
6780
|
-
if (fFmt) VpFormatSt(buf, fFmt);
|
6781
6802
|
|
6782
6803
|
overflow:
|
6783
6804
|
return;
|
6784
|
-
#undef
|
6805
|
+
#undef APPEND
|
6785
6806
|
}
|
6786
6807
|
|
6787
6808
|
/*
|
@@ -7158,7 +7179,6 @@ VpSqrt(Real *y, Real *x)
|
|
7158
7179
|
Real *r = NULL;
|
7159
7180
|
size_t y_prec;
|
7160
7181
|
SIGNED_VALUE n, e;
|
7161
|
-
SIGNED_VALUE prec;
|
7162
7182
|
ssize_t nr;
|
7163
7183
|
double val;
|
7164
7184
|
|
@@ -7197,12 +7217,6 @@ VpSqrt(Real *y, Real *x)
|
|
7197
7217
|
nr = 0;
|
7198
7218
|
y_prec = y->MaxPrec;
|
7199
7219
|
|
7200
|
-
prec = x->exponent - (ssize_t)y_prec;
|
7201
|
-
if (x->exponent > 0)
|
7202
|
-
++prec;
|
7203
|
-
else
|
7204
|
-
--prec;
|
7205
|
-
|
7206
7220
|
VpVtoD(&val, &e, x); /* val <- x */
|
7207
7221
|
e /= (SIGNED_VALUE)BASE_FIG;
|
7208
7222
|
n = e / 2;
|
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/util.rb
CHANGED
@@ -18,7 +18,7 @@ class Integer < Numeric
|
|
18
18
|
#
|
19
19
|
# 42.to_d # => 0.42e2
|
20
20
|
#
|
21
|
-
# See also BigDecimal
|
21
|
+
# See also Kernel.BigDecimal.
|
22
22
|
#
|
23
23
|
def to_d
|
24
24
|
BigDecimal(self)
|
@@ -45,7 +45,7 @@ class Float < Numeric
|
|
45
45
|
# 1.234.to_d # => 0.1234e1
|
46
46
|
# 1.234.to_d(2) # => 0.12e1
|
47
47
|
#
|
48
|
-
# See also BigDecimal
|
48
|
+
# See also Kernel.BigDecimal.
|
49
49
|
#
|
50
50
|
def to_d(precision=0)
|
51
51
|
BigDecimal(self, precision)
|
@@ -67,7 +67,7 @@ class String
|
|
67
67
|
# "123.45e1".to_d # => 0.12345e4
|
68
68
|
# "45.67 degrees".to_d # => 0.4567e2
|
69
69
|
#
|
70
|
-
# See also BigDecimal
|
70
|
+
# See also Kernel.BigDecimal.
|
71
71
|
#
|
72
72
|
def to_d
|
73
73
|
BigDecimal.interpret_loosely(self)
|
@@ -127,7 +127,7 @@ class Rational < Numeric
|
|
127
127
|
#
|
128
128
|
# Rational(22, 7).to_d(3) # => 0.314e1
|
129
129
|
#
|
130
|
-
# See also BigDecimal
|
130
|
+
# See also Kernel.BigDecimal.
|
131
131
|
#
|
132
132
|
def to_d(precision)
|
133
133
|
BigDecimal(self, precision)
|
@@ -152,7 +152,7 @@ class Complex < Numeric
|
|
152
152
|
# Complex(0.1234567, 0).to_d(4) # => 0.1235e0
|
153
153
|
# Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
|
154
154
|
#
|
155
|
-
# See also BigDecimal
|
155
|
+
# See also Kernel.BigDecimal.
|
156
156
|
#
|
157
157
|
def to_d(*args)
|
158
158
|
BigDecimal(self) unless self.imag.zero? # to raise eerror
|
data/lib/bigdecimal.rb
CHANGED
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: 3.1.
|
4
|
+
version: 3.1.5
|
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:
|
13
|
+
date: 2023-12-13 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: This library provides arbitrary-precision decimal floating-point number
|
16
16
|
class.
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
homepage: https://github.com/ruby/bigdecimal
|
44
44
|
licenses:
|
45
45
|
- Ruby
|
46
|
-
-
|
46
|
+
- BSD-2-Clause
|
47
47
|
metadata: {}
|
48
48
|
post_install_message:
|
49
49
|
rdoc_options: []
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
63
|
+
rubygems_version: 3.3.9
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Arbitrary-precision decimal floating-point number library.
|