bigdecimal 1.2.7 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bigdecimal.gemspec +26 -18
- data/{bigdecimal.c → ext/bigdecimal/bigdecimal.c} +481 -340
- data/{bigdecimal.h → ext/bigdecimal/bigdecimal.h} +83 -10
- data/ext/bigdecimal/extconf.rb +35 -0
- data/lib/bigdecimal/jacobian.rb +1 -0
- data/lib/bigdecimal/ludcmp.rb +1 -0
- data/lib/bigdecimal/math.rb +10 -9
- data/lib/bigdecimal/newton.rb +1 -0
- data/lib/bigdecimal/util.rb +58 -51
- data/sample/linear.rb +12 -10
- data/sample/nlsolve.rb +6 -5
- data/sample/pi.rb +1 -0
- metadata +85 -14
- data/README +0 -60
- data/extconf.rb +0 -10
- data/{depend → ext/bigdecimal/depend} +1 -1
@@ -4,18 +4,13 @@
|
|
4
4
|
*
|
5
5
|
* Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
|
6
6
|
*
|
7
|
-
* You may distribute under the terms of either the GNU General Public
|
8
|
-
* License or the Artistic License, as specified in the README file
|
9
|
-
* of this BigDecimal distribution.
|
10
|
-
*
|
11
|
-
* NOTES:
|
12
|
-
* 2003-03-28 V1.0 checked in.
|
13
|
-
*
|
14
7
|
*/
|
15
8
|
|
16
9
|
#ifndef RUBY_BIG_DECIMAL_H
|
17
10
|
#define RUBY_BIG_DECIMAL_H 1
|
18
11
|
|
12
|
+
#define RUBY_NO_OLD_COMPATIBILITY
|
13
|
+
|
19
14
|
#include "ruby/ruby.h"
|
20
15
|
#include <float.h>
|
21
16
|
|
@@ -43,13 +38,35 @@
|
|
43
38
|
# define BDIGIT_DBL uint64_t
|
44
39
|
# define BDIGIT_DBL_SIGNED int64_t
|
45
40
|
# define SIZEOF_BDIGITS 4
|
41
|
+
# define PRI_BDIGIT_PREFIX ""
|
42
|
+
# ifdef PRI_LL_PREFIX
|
43
|
+
# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
|
44
|
+
# else
|
45
|
+
# define PRI_BDIGIT_DBL_PREFIX "l"
|
46
|
+
# endif
|
46
47
|
#else
|
47
48
|
# define BDIGIT uint16_t
|
48
49
|
# define BDIGIT_DBL uint32_t
|
49
50
|
# define BDIGIT_DBL_SIGNED int32_t
|
50
51
|
# define SIZEOF_BDIGITS 2
|
52
|
+
# define PRI_BDIGIT_PREFIX "h"
|
53
|
+
# define PRI_BDIGIT_DBL_PREFIX ""
|
51
54
|
#endif
|
52
55
|
|
56
|
+
#define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
|
57
|
+
#define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
|
58
|
+
#define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
|
59
|
+
#define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
|
60
|
+
#define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
|
61
|
+
#define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
|
62
|
+
|
63
|
+
#define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
|
64
|
+
#define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
|
65
|
+
#define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
|
66
|
+
#define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
|
67
|
+
#define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
|
68
|
+
#define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
|
69
|
+
|
53
70
|
#if defined(__cplusplus)
|
54
71
|
extern "C" {
|
55
72
|
#if 0
|
@@ -75,6 +92,62 @@ llabs(LONG_LONG const x)
|
|
75
92
|
}
|
76
93
|
#endif
|
77
94
|
|
95
|
+
#ifndef HAVE_FINITE
|
96
|
+
static int
|
97
|
+
finite(double)
|
98
|
+
{
|
99
|
+
return !isnan(n) && !isinf(n);
|
100
|
+
}
|
101
|
+
#endif
|
102
|
+
|
103
|
+
#ifndef isfinite
|
104
|
+
# ifndef HAVE_ISFINITE
|
105
|
+
# define HAVE_ISFINITE 1
|
106
|
+
# define isfinite(x) finite(x)
|
107
|
+
# endif
|
108
|
+
#endif
|
109
|
+
|
110
|
+
#ifndef FIX_CONST_VALUE_PTR
|
111
|
+
# if defined(__fcc__) || defined(__fcc_version) || \
|
112
|
+
defined(__FCC__) || defined(__FCC_VERSION)
|
113
|
+
/* workaround for old version of Fujitsu C Compiler (fcc) */
|
114
|
+
# define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
|
115
|
+
# else
|
116
|
+
# define FIX_CONST_VALUE_PTR(x) (x)
|
117
|
+
# endif
|
118
|
+
#endif
|
119
|
+
|
120
|
+
#ifndef HAVE_RB_ARRAY_CONST_PTR
|
121
|
+
static inline const VALUE *
|
122
|
+
rb_array_const_ptr(VALUE a)
|
123
|
+
{
|
124
|
+
return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
|
125
|
+
RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
|
126
|
+
}
|
127
|
+
#endif
|
128
|
+
|
129
|
+
#ifndef RARRAY_CONST_PTR
|
130
|
+
# define RARRAY_CONST_PTR(a) rb_array_const_ptr(a)
|
131
|
+
#endif
|
132
|
+
|
133
|
+
#ifndef RARRAY_AREF
|
134
|
+
# define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i])
|
135
|
+
#endif
|
136
|
+
|
137
|
+
#ifndef HAVE_RB_SYM2STR
|
138
|
+
static inline VALUE
|
139
|
+
rb_sym2str(VALUE sym)
|
140
|
+
{
|
141
|
+
return rb_id2str(SYM2ID(sym));
|
142
|
+
}
|
143
|
+
#endif
|
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
|
+
|
78
151
|
#ifdef vabs
|
79
152
|
# undef vabs
|
80
153
|
#endif
|
@@ -167,11 +240,11 @@ extern VALUE rb_cBigDecimal;
|
|
167
240
|
typedef struct {
|
168
241
|
VALUE obj; /* Back pointer(VALUE) for Ruby object. */
|
169
242
|
size_t MaxPrec; /* Maximum precision size */
|
170
|
-
/* This is the actual size of
|
243
|
+
/* This is the actual size of frac[] */
|
171
244
|
/*(frac[0] to frac[MaxPrec] are available). */
|
172
245
|
size_t Prec; /* Current precision size. */
|
173
|
-
/* This indicates how much the
|
174
|
-
/*
|
246
|
+
/* This indicates how much the */
|
247
|
+
/* array frac[] is actually used. */
|
175
248
|
SIGNED_VALUE exponent; /* Exponent part. */
|
176
249
|
short sign; /* Attributes of the value. */
|
177
250
|
/*
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
gemspec_name = gemspec_path = nil
|
5
|
+
unless ['', '../../'].any? {|dir|
|
6
|
+
gemspec_name = "#{dir}bigdecimal.gemspec"
|
7
|
+
gemspec_path = File.expand_path("../#{gemspec_name}", __FILE__)
|
8
|
+
File.file?(gemspec_path)
|
9
|
+
}
|
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
|
+
|
20
|
+
alias __have_macro__ have_macro
|
21
|
+
|
22
|
+
have_func("labs", "stdlib.h")
|
23
|
+
have_func("llabs", "stdlib.h")
|
24
|
+
have_func("finite", "math.h")
|
25
|
+
have_func("isfinite", "math.h")
|
26
|
+
|
27
|
+
have_type("struct RRational", "ruby.h")
|
28
|
+
have_func("rb_rational_num", "ruby.h")
|
29
|
+
have_func("rb_rational_den", "ruby.h")
|
30
|
+
have_func("rb_array_const_ptr", "ruby.h")
|
31
|
+
have_func("rb_sym2str", "ruby.h")
|
32
|
+
|
33
|
+
create_makefile('bigdecimal') {|mf|
|
34
|
+
mf << "\nall:\n\nextconf.h: $(srcdir)/#{gemspec_name}\n"
|
35
|
+
}
|
data/lib/bigdecimal/jacobian.rb
CHANGED
data/lib/bigdecimal/ludcmp.rb
CHANGED
data/lib/bigdecimal/math.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: false
|
1
2
|
require 'bigdecimal'
|
2
3
|
|
3
4
|
#
|
@@ -25,7 +26,7 @@ require 'bigdecimal'
|
|
25
26
|
# include BigMath
|
26
27
|
#
|
27
28
|
# a = BigDecimal((PI(100)/2).to_s)
|
28
|
-
# puts sin(a,100) # => 0.
|
29
|
+
# puts sin(a,100) # => 0.99999999999999999999......e0
|
29
30
|
#
|
30
31
|
module BigMath
|
31
32
|
module_function
|
@@ -36,8 +37,8 @@ module BigMath
|
|
36
37
|
# Computes the square root of +decimal+ to the specified number of digits of
|
37
38
|
# precision, +numeric+.
|
38
39
|
#
|
39
|
-
# BigMath.sqrt(BigDecimal
|
40
|
-
# #=> "0.
|
40
|
+
# BigMath.sqrt(BigDecimal('2'), 16).to_s
|
41
|
+
# #=> "0.1414213562373095048801688724e1"
|
41
42
|
#
|
42
43
|
def sqrt(x, prec)
|
43
44
|
x.sqrt(prec)
|
@@ -52,7 +53,7 @@ module BigMath
|
|
52
53
|
# If +decimal+ is Infinity or NaN, returns NaN.
|
53
54
|
#
|
54
55
|
# BigMath.sin(BigMath.PI(5)/4, 5).to_s
|
55
|
-
# #=> "0.
|
56
|
+
# #=> "0.70710678118654752440082036563292800375e0"
|
56
57
|
#
|
57
58
|
def sin(x, prec)
|
58
59
|
raise ArgumentError, "Zero or negative precision for sin" if prec <= 0
|
@@ -96,7 +97,7 @@ module BigMath
|
|
96
97
|
# If +decimal+ is Infinity or NaN, returns NaN.
|
97
98
|
#
|
98
99
|
# BigMath.cos(BigMath.PI(4), 16).to_s
|
99
|
-
# #=> "-0.
|
100
|
+
# #=> "-0.999999999999999999999999999999856613163740061349e0"
|
100
101
|
#
|
101
102
|
def cos(x, prec)
|
102
103
|
raise ArgumentError, "Zero or negative precision for cos" if prec <= 0
|
@@ -139,8 +140,8 @@ module BigMath
|
|
139
140
|
#
|
140
141
|
# If +decimal+ is NaN, returns NaN.
|
141
142
|
#
|
142
|
-
# BigMath.atan(BigDecimal
|
143
|
-
# #=> "-0.
|
143
|
+
# BigMath.atan(BigDecimal('-1'), 16).to_s
|
144
|
+
# #=> "-0.785398163397448309615660845819878471907514682065e0"
|
144
145
|
#
|
145
146
|
def atan(x, prec)
|
146
147
|
raise ArgumentError, "Zero or negative precision for atan" if prec <= 0
|
@@ -177,7 +178,7 @@ module BigMath
|
|
177
178
|
# +numeric+.
|
178
179
|
#
|
179
180
|
# BigMath.PI(10).to_s
|
180
|
-
# #=> "0.
|
181
|
+
# #=> "0.3141592653589793238462643388813853786957412e1"
|
181
182
|
#
|
182
183
|
def PI(prec)
|
183
184
|
raise ArgumentError, "Zero or negative precision for PI" if prec <= 0
|
@@ -222,7 +223,7 @@ module BigMath
|
|
222
223
|
# digits of precision, +numeric+.
|
223
224
|
#
|
224
225
|
# BigMath.E(10).to_s
|
225
|
-
# #=> "0.
|
226
|
+
# #=> "0.271828182845904523536028752390026306410273e1"
|
226
227
|
#
|
227
228
|
def E(prec)
|
228
229
|
raise ArgumentError, "Zero or negative precision for E" if prec <= 0
|
data/lib/bigdecimal/newton.rb
CHANGED
data/lib/bigdecimal/util.rb
CHANGED
@@ -1,71 +1,79 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: false
|
2
2
|
#
|
3
|
-
|
4
|
-
#
|
3
|
+
#--
|
4
|
+
# bigdecimal/util extends various native classes to provide the #to_d method,
|
5
|
+
# and provides BigDecimal#to_d and BigDecimal#to_digits.
|
6
|
+
#++
|
7
|
+
|
8
|
+
|
5
9
|
class Integer < Numeric
|
6
10
|
# call-seq:
|
7
11
|
# int.to_d -> bigdecimal
|
8
12
|
#
|
9
|
-
#
|
13
|
+
# Returns the value of +int+ as a BigDecimal.
|
10
14
|
#
|
11
15
|
# require 'bigdecimal'
|
12
16
|
# require 'bigdecimal/util'
|
13
17
|
#
|
14
|
-
# 42.to_d
|
15
|
-
#
|
18
|
+
# 42.to_d # => 0.42e2
|
19
|
+
#
|
20
|
+
# See also BigDecimal::new.
|
16
21
|
#
|
17
22
|
def to_d
|
18
23
|
BigDecimal(self)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
|
-
|
23
|
-
#
|
24
|
-
# When you require BigDecimal in your application, this method will be
|
25
|
-
# available on Float objects.
|
27
|
+
|
26
28
|
class Float < Numeric
|
27
29
|
# call-seq:
|
28
|
-
#
|
30
|
+
# float.to_d -> bigdecimal
|
31
|
+
# float.to_d(precision) -> bigdecimal
|
29
32
|
#
|
30
|
-
#
|
33
|
+
# Returns the value of +float+ as a BigDecimal.
|
34
|
+
# The +precision+ parameter is used to determine the number of
|
35
|
+
# significant digits for the result (the default is Float::DIG).
|
31
36
|
#
|
32
37
|
# require 'bigdecimal'
|
33
38
|
# require 'bigdecimal/util'
|
34
39
|
#
|
35
|
-
# 0.5.to_d
|
36
|
-
# # =>
|
40
|
+
# 0.5.to_d # => 0.5e0
|
41
|
+
# 1.234.to_d(2) # => 0.12e1
|
42
|
+
#
|
43
|
+
# See also BigDecimal::new.
|
37
44
|
#
|
38
45
|
def to_d(precision=nil)
|
39
46
|
BigDecimal(self, precision || Float::DIG)
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
43
|
-
|
44
|
-
#
|
45
|
-
# When you require BigDecimal in your application, this method will be
|
46
|
-
# available on String objects.
|
50
|
+
|
47
51
|
class String
|
48
52
|
# call-seq:
|
49
|
-
#
|
53
|
+
# str.to_d -> bigdecimal
|
50
54
|
#
|
51
|
-
#
|
55
|
+
# Returns the result of interpreting leading characters in +str+
|
56
|
+
# as a BigDecimal.
|
52
57
|
#
|
53
58
|
# require 'bigdecimal'
|
54
59
|
# require 'bigdecimal/util'
|
55
60
|
#
|
56
|
-
# "0.5".to_d
|
57
|
-
# # =>
|
61
|
+
# "0.5".to_d # => 0.5e0
|
62
|
+
# "123.45e1".to_d # => 0.12345e4
|
63
|
+
# "45.67 degrees".to_d # => 0.4567e2
|
64
|
+
#
|
65
|
+
# See also BigDecimal::new.
|
58
66
|
#
|
59
67
|
def to_d
|
60
|
-
|
68
|
+
begin
|
69
|
+
BigDecimal(self)
|
70
|
+
rescue ArgumentError
|
71
|
+
BigDecimal(0)
|
72
|
+
end
|
61
73
|
end
|
62
74
|
end
|
63
75
|
|
64
|
-
|
65
|
-
# #to_d methods.
|
66
|
-
#
|
67
|
-
# When you require BigDecimal in your application, this method will be
|
68
|
-
# available on BigDecimal objects.
|
76
|
+
|
69
77
|
class BigDecimal < Numeric
|
70
78
|
# call-seq:
|
71
79
|
# a.to_digits -> string
|
@@ -73,12 +81,11 @@ class BigDecimal < Numeric
|
|
73
81
|
# Converts a BigDecimal to a String of the form "nnnnnn.mmm".
|
74
82
|
# This method is deprecated; use BigDecimal#to_s("F") instead.
|
75
83
|
#
|
76
|
-
# require 'bigdecimal'
|
77
84
|
# require 'bigdecimal/util'
|
78
85
|
#
|
79
|
-
# d = BigDecimal
|
80
|
-
# d.to_digits
|
81
|
-
#
|
86
|
+
# d = BigDecimal("3.14")
|
87
|
+
# d.to_digits # => "3.14"
|
88
|
+
#
|
82
89
|
def to_digits
|
83
90
|
if self.nan? || self.infinite? || self.zero?
|
84
91
|
self.to_s
|
@@ -93,35 +100,35 @@ class BigDecimal < Numeric
|
|
93
100
|
# a.to_d -> bigdecimal
|
94
101
|
#
|
95
102
|
# Returns self.
|
103
|
+
#
|
104
|
+
# require 'bigdecimal/util'
|
105
|
+
#
|
106
|
+
# d = BigDecimal("3.14")
|
107
|
+
# d.to_d # => 0.314e1
|
108
|
+
#
|
96
109
|
def to_d
|
97
110
|
self
|
98
111
|
end
|
99
112
|
end
|
100
113
|
|
101
|
-
|
102
|
-
#
|
103
|
-
# When you require BigDecimal in your application, this method will be
|
104
|
-
# available on Rational objects.
|
114
|
+
|
105
115
|
class Rational < Numeric
|
106
116
|
# call-seq:
|
107
|
-
#
|
117
|
+
# rat.to_d(precision) -> bigdecimal
|
108
118
|
#
|
109
|
-
#
|
119
|
+
# Returns the value as a BigDecimal.
|
110
120
|
#
|
111
|
-
# The required +precision+ parameter is used to determine the
|
112
|
-
# significant digits for the result.
|
113
|
-
#
|
114
|
-
#
|
121
|
+
# The required +precision+ parameter is used to determine the number of
|
122
|
+
# significant digits for the result.
|
123
|
+
#
|
124
|
+
# require 'bigdecimal'
|
125
|
+
# require 'bigdecimal/util'
|
126
|
+
#
|
127
|
+
# Rational(22, 7).to_d(3) # => 0.314e1
|
128
|
+
#
|
129
|
+
# See also BigDecimal::new.
|
115
130
|
#
|
116
|
-
# r = (22/7.0).to_r
|
117
|
-
# # => (7077085128725065/2251799813685248)
|
118
|
-
# r.to_d(3)
|
119
|
-
# # => #<BigDecimal:1a44d08,'0.314E1',18(36)>
|
120
131
|
def to_d(precision)
|
121
|
-
|
122
|
-
raise ArgumentError, "negative precision"
|
123
|
-
end
|
124
|
-
num = self.numerator
|
125
|
-
BigDecimal(num).div(self.denominator, precision)
|
132
|
+
BigDecimal(self, precision)
|
126
133
|
end
|
127
134
|
end
|
data/sample/linear.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/local/bin/ruby
|
2
|
+
# frozen_string_literal: false
|
2
3
|
|
3
4
|
#
|
4
5
|
# linear.rb
|
@@ -27,8 +28,8 @@ def rd_order(na)
|
|
27
28
|
end
|
28
29
|
|
29
30
|
na = ARGV.size
|
30
|
-
zero = BigDecimal
|
31
|
-
one = BigDecimal
|
31
|
+
zero = BigDecimal("0.0")
|
32
|
+
one = BigDecimal("1.0")
|
32
33
|
|
33
34
|
while (n=rd_order(na))>0
|
34
35
|
a = []
|
@@ -36,27 +37,28 @@ while (n=rd_order(na))>0
|
|
36
37
|
b = []
|
37
38
|
if na <= 0
|
38
39
|
# Read data from console.
|
39
|
-
printf("\nEnter coefficient matrix element A[i,j]\n")
|
40
|
+
printf("\nEnter coefficient matrix element A[i,j]\n")
|
40
41
|
for i in 0...n do
|
41
42
|
for j in 0...n do
|
42
43
|
printf("A[%d,%d]? ",i,j); s = ARGF.gets
|
43
|
-
a << BigDecimal
|
44
|
-
as << BigDecimal
|
44
|
+
a << BigDecimal(s)
|
45
|
+
as << BigDecimal(s)
|
45
46
|
end
|
46
|
-
printf("Contatant vector element b[%d] ? ",i)
|
47
|
+
printf("Contatant vector element b[%d] ? ",i)
|
48
|
+
b << BigDecimal(ARGF.gets)
|
47
49
|
end
|
48
50
|
else
|
49
51
|
# Read data from specified file.
|
50
|
-
printf("Coefficient matrix and constant vector.\n")
|
52
|
+
printf("Coefficient matrix and constant vector.\n")
|
51
53
|
for i in 0...n do
|
52
54
|
s = ARGF.gets
|
53
55
|
printf("%d) %s",i,s)
|
54
56
|
s = s.split
|
55
57
|
for j in 0...n do
|
56
|
-
a << BigDecimal
|
57
|
-
as << BigDecimal
|
58
|
+
a << BigDecimal(s[j])
|
59
|
+
as << BigDecimal(s[j])
|
58
60
|
end
|
59
|
-
b << BigDecimal
|
61
|
+
b << BigDecimal(s[n])
|
60
62
|
end
|
61
63
|
end
|
62
64
|
x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
|
data/sample/nlsolve.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/local/bin/ruby
|
2
|
+
# frozen_string_literal: false
|
2
3
|
|
3
4
|
#
|
4
5
|
# nlsolve.rb
|
@@ -11,11 +12,11 @@ include Newton
|
|
11
12
|
|
12
13
|
class Function # :nodoc: all
|
13
14
|
def initialize()
|
14
|
-
@zero = BigDecimal
|
15
|
-
@one = BigDecimal
|
16
|
-
@two = BigDecimal
|
17
|
-
@ten = BigDecimal
|
18
|
-
@eps = BigDecimal
|
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")
|
19
20
|
end
|
20
21
|
def zero;@zero;end
|
21
22
|
def one ;@one ;end
|
data/sample/pi.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: 1.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Murata
|
@@ -10,22 +10,92 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2017-12-24 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '10.0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '10.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake-compiler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.9'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
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
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: minitest
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 4.7.5
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 4.7.5
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: pry
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
15
85
|
description: This library provides arbitrary-precision decimal floating-point number
|
16
86
|
class.
|
17
|
-
email:
|
87
|
+
email:
|
88
|
+
- mrkn@mrkn.jp
|
18
89
|
executables: []
|
19
90
|
extensions:
|
20
|
-
- extconf.rb
|
91
|
+
- ext/bigdecimal/extconf.rb
|
21
92
|
extra_rdoc_files: []
|
22
93
|
files:
|
23
|
-
- README
|
24
|
-
- bigdecimal.c
|
25
94
|
- bigdecimal.gemspec
|
26
|
-
- bigdecimal.
|
27
|
-
-
|
28
|
-
-
|
95
|
+
- ext/bigdecimal/bigdecimal.c
|
96
|
+
- ext/bigdecimal/bigdecimal.h
|
97
|
+
- ext/bigdecimal/depend
|
98
|
+
- ext/bigdecimal/extconf.rb
|
29
99
|
- lib/bigdecimal/jacobian.rb
|
30
100
|
- lib/bigdecimal/ludcmp.rb
|
31
101
|
- lib/bigdecimal/math.rb
|
@@ -34,13 +104,14 @@ files:
|
|
34
104
|
- sample/linear.rb
|
35
105
|
- sample/nlsolve.rb
|
36
106
|
- sample/pi.rb
|
37
|
-
homepage:
|
38
|
-
licenses:
|
107
|
+
homepage: https://github.com/ruby/bigdecimal
|
108
|
+
licenses:
|
109
|
+
- ruby
|
39
110
|
metadata: {}
|
40
111
|
post_install_message:
|
41
112
|
rdoc_options: []
|
42
113
|
require_paths:
|
43
|
-
-
|
114
|
+
- lib
|
44
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
116
|
requirements:
|
46
117
|
- - ">="
|
@@ -53,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
124
|
version: '0'
|
54
125
|
requirements: []
|
55
126
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.6.14
|
57
128
|
signing_key:
|
58
129
|
specification_version: 4
|
59
130
|
summary: Arbitrary-precision decimal floating-point number library.
|