bigdecimal 1.2.7 → 1.3.0.pre
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 +23 -18
- data/{bigdecimal.c → ext/bigdecimal/bigdecimal.c} +325 -257
- data/{bigdecimal.h → ext/bigdecimal/bigdecimal.h} +75 -10
- data/{depend → ext/bigdecimal/depend} +1 -1
- data/ext/bigdecimal/extconf.rb +30 -0
- data/lib/bigdecimal/jacobian.rb +1 -0
- data/lib/bigdecimal/ludcmp.rb +1 -0
- data/lib/bigdecimal/math.rb +1 -0
- data/lib/bigdecimal/newton.rb +1 -0
- data/lib/bigdecimal/util.rb +2 -1
- data/sample/linear.rb +1 -0
- data/sample/nlsolve.rb +1 -0
- data/sample/pi.rb +1 -0
- metadata +59 -16
- data/README +0 -60
- data/extconf.rb +0 -10
@@ -4,13 +4,6 @@
|
|
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
|
@@ -43,13 +36,35 @@
|
|
43
36
|
# define BDIGIT_DBL uint64_t
|
44
37
|
# define BDIGIT_DBL_SIGNED int64_t
|
45
38
|
# define SIZEOF_BDIGITS 4
|
39
|
+
# define PRI_BDIGIT_PREFIX ""
|
40
|
+
# ifdef PRI_LL_PREFIX
|
41
|
+
# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
|
42
|
+
# else
|
43
|
+
# define PRI_BDIGIT_DBL_PREFIX "l"
|
44
|
+
# endif
|
46
45
|
#else
|
47
46
|
# define BDIGIT uint16_t
|
48
47
|
# define BDIGIT_DBL uint32_t
|
49
48
|
# define BDIGIT_DBL_SIGNED int32_t
|
50
49
|
# define SIZEOF_BDIGITS 2
|
50
|
+
# define PRI_BDIGIT_PREFIX "h"
|
51
|
+
# define PRI_BDIGIT_DBL_PREFIX ""
|
51
52
|
#endif
|
52
53
|
|
54
|
+
#define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
|
55
|
+
#define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
|
56
|
+
#define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
|
57
|
+
#define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
|
58
|
+
#define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
|
59
|
+
#define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
|
60
|
+
|
61
|
+
#define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
|
62
|
+
#define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
|
63
|
+
#define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
|
64
|
+
#define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
|
65
|
+
#define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
|
66
|
+
#define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
|
67
|
+
|
53
68
|
#if defined(__cplusplus)
|
54
69
|
extern "C" {
|
55
70
|
#if 0
|
@@ -75,6 +90,56 @@ llabs(LONG_LONG const x)
|
|
75
90
|
}
|
76
91
|
#endif
|
77
92
|
|
93
|
+
#ifndef HAVE_FINITE
|
94
|
+
static int
|
95
|
+
finite(double)
|
96
|
+
{
|
97
|
+
return !isnan(n) && !isinf(n);
|
98
|
+
}
|
99
|
+
#endif
|
100
|
+
|
101
|
+
#ifndef isfinite
|
102
|
+
# ifndef HAVE_ISFINITE
|
103
|
+
# define HAVE_ISFINITE 1
|
104
|
+
# define isfinite(x) finite(x)
|
105
|
+
# endif
|
106
|
+
#endif
|
107
|
+
|
108
|
+
#ifndef FIX_CONST_VALUE_PTR
|
109
|
+
# if defined(__fcc__) || defined(__fcc_version) || \
|
110
|
+
defined(__FCC__) || defined(__FCC_VERSION)
|
111
|
+
/* workaround for old version of Fujitsu C Compiler (fcc) */
|
112
|
+
# define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
|
113
|
+
# else
|
114
|
+
# define FIX_CONST_VALUE_PTR(x) (x)
|
115
|
+
# endif
|
116
|
+
#endif
|
117
|
+
|
118
|
+
#ifndef HAVE_RB_ARRAY_CONST_PTR
|
119
|
+
static inline const VALUE *
|
120
|
+
rb_array_const_ptr(VALUE a)
|
121
|
+
{
|
122
|
+
return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
|
123
|
+
RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
|
124
|
+
}
|
125
|
+
#endif
|
126
|
+
|
127
|
+
#ifndef RARRAY_CONST_PTR
|
128
|
+
# define RARRAY_CONST_PTR(a) rb_array_const_ptr(a)
|
129
|
+
#endif
|
130
|
+
|
131
|
+
#ifndef RARRAY_AREF
|
132
|
+
# define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i])
|
133
|
+
#endif
|
134
|
+
|
135
|
+
#ifndef HAVE_RB_SYM2STR
|
136
|
+
static inline VALUE
|
137
|
+
rb_sym2str(VALUE sym)
|
138
|
+
{
|
139
|
+
return rb_id2str(SYM2ID(sym));
|
140
|
+
}
|
141
|
+
#endif
|
142
|
+
|
78
143
|
#ifdef vabs
|
79
144
|
# undef vabs
|
80
145
|
#endif
|
@@ -167,11 +232,11 @@ extern VALUE rb_cBigDecimal;
|
|
167
232
|
typedef struct {
|
168
233
|
VALUE obj; /* Back pointer(VALUE) for Ruby object. */
|
169
234
|
size_t MaxPrec; /* Maximum precision size */
|
170
|
-
/* This is the actual size of
|
235
|
+
/* This is the actual size of frac[] */
|
171
236
|
/*(frac[0] to frac[MaxPrec] are available). */
|
172
237
|
size_t Prec; /* Current precision size. */
|
173
|
-
/* This indicates how much the
|
174
|
-
/*
|
238
|
+
/* This indicates how much the */
|
239
|
+
/* array frac[] is actually used. */
|
175
240
|
SIGNED_VALUE exponent; /* Exponent part. */
|
176
241
|
short sign; /* Attributes of the value. */
|
177
242
|
/*
|
@@ -4,10 +4,10 @@ bigdecimal.o: $(arch_hdrdir)/ruby/config.h
|
|
4
4
|
bigdecimal.o: $(hdrdir)/ruby/defines.h
|
5
5
|
bigdecimal.o: $(hdrdir)/ruby/intern.h
|
6
6
|
bigdecimal.o: $(hdrdir)/ruby/missing.h
|
7
|
+
bigdecimal.o: $(hdrdir)/ruby/ruby.h
|
7
8
|
bigdecimal.o: $(hdrdir)/ruby/st.h
|
8
9
|
bigdecimal.o: $(hdrdir)/ruby/subst.h
|
9
10
|
bigdecimal.o: $(hdrdir)/ruby/util.h
|
10
|
-
bigdecimal.o: $(hdrdir)/ruby/ruby.h
|
11
11
|
bigdecimal.o: bigdecimal.c
|
12
12
|
bigdecimal.o: bigdecimal.h
|
13
13
|
# AUTOGENERATED DEPENDENCIES END
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
alias __have_macro__ have_macro
|
5
|
+
|
6
|
+
have_func("labs", "stdlib.h")
|
7
|
+
have_func("llabs", "stdlib.h")
|
8
|
+
have_func("finite", "math.h")
|
9
|
+
have_func("isfinite", "math.h")
|
10
|
+
|
11
|
+
have_type("struct RRational", "ruby.h")
|
12
|
+
have_func("rb_rational_num", "ruby.h")
|
13
|
+
have_func("rb_rational_den", "ruby.h")
|
14
|
+
have_func("rb_array_const_ptr", "ruby.h")
|
15
|
+
have_func("rb_sym2str", "ruby.h")
|
16
|
+
|
17
|
+
have_macro("FIX_CONST_VALUE_PTR", "ruby.h")
|
18
|
+
have_macro("RARRAY_CONST_PTR", "ruby.h")
|
19
|
+
have_macro("RARRAY_AREF", "ruby.h")
|
20
|
+
|
21
|
+
create_makefile('bigdecimal')
|
22
|
+
|
23
|
+
# Add additional dependencies
|
24
|
+
open('Makefile', 'a') do |io|
|
25
|
+
if RUBY_VERSION >= '2.4'
|
26
|
+
io.puts <<-MAKEFILE
|
27
|
+
bigdecimal.o: $(hdrdir)/ruby/backward.h
|
28
|
+
MAKEFILE
|
29
|
+
end
|
30
|
+
end
|
data/lib/bigdecimal/jacobian.rb
CHANGED
data/lib/bigdecimal/ludcmp.rb
CHANGED
data/lib/bigdecimal/math.rb
CHANGED
data/lib/bigdecimal/newton.rb
CHANGED
data/lib/bigdecimal/util.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: false
|
1
2
|
# BigDecimal extends the native Integer class to provide the #to_d method.
|
2
3
|
#
|
3
|
-
# When you require the BigDecimal library in your application, this
|
4
|
+
# When you require the BigDecimal library in your application, this method will
|
4
5
|
# be available on Integer objects.
|
5
6
|
class Integer < Numeric
|
6
7
|
# call-seq:
|
data/sample/linear.rb
CHANGED
data/sample/nlsolve.rb
CHANGED
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.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Murata
|
@@ -10,22 +10,64 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
13
|
+
date: 2016-12-10 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: minitest
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 4.7.5
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 4.7.5
|
15
57
|
description: This library provides arbitrary-precision decimal floating-point number
|
16
58
|
class.
|
17
|
-
email:
|
59
|
+
email:
|
60
|
+
- mrkn@mrkn.jp
|
18
61
|
executables: []
|
19
62
|
extensions:
|
20
|
-
- extconf.rb
|
63
|
+
- ext/bigdecimal/extconf.rb
|
21
64
|
extra_rdoc_files: []
|
22
65
|
files:
|
23
|
-
- README
|
24
|
-
- bigdecimal.c
|
25
66
|
- bigdecimal.gemspec
|
26
|
-
- bigdecimal.
|
27
|
-
-
|
28
|
-
-
|
67
|
+
- ext/bigdecimal/bigdecimal.c
|
68
|
+
- ext/bigdecimal/bigdecimal.h
|
69
|
+
- ext/bigdecimal/depend
|
70
|
+
- ext/bigdecimal/extconf.rb
|
29
71
|
- lib/bigdecimal/jacobian.rb
|
30
72
|
- lib/bigdecimal/ludcmp.rb
|
31
73
|
- lib/bigdecimal/math.rb
|
@@ -34,13 +76,14 @@ files:
|
|
34
76
|
- sample/linear.rb
|
35
77
|
- sample/nlsolve.rb
|
36
78
|
- sample/pi.rb
|
37
|
-
homepage:
|
38
|
-
licenses:
|
79
|
+
homepage: https://github.com/ruby/bigdecimal
|
80
|
+
licenses:
|
81
|
+
- ruby
|
39
82
|
metadata: {}
|
40
83
|
post_install_message:
|
41
84
|
rdoc_options: []
|
42
85
|
require_paths:
|
43
|
-
-
|
86
|
+
- lib
|
44
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
88
|
requirements:
|
46
89
|
- - ">="
|
@@ -48,12 +91,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
91
|
version: '0'
|
49
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
93
|
requirements:
|
51
|
-
- - "
|
94
|
+
- - ">"
|
52
95
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
96
|
+
version: 1.3.1
|
54
97
|
requirements: []
|
55
98
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.6.7
|
57
100
|
signing_key:
|
58
101
|
specification_version: 4
|
59
102
|
summary: Arbitrary-precision decimal floating-point number library.
|
data/README
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
|
2
|
-
Ruby BIGDECIMAL(Variable Precision) extension library.
|
3
|
-
Copyright (C) 1999 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
|
4
|
-
|
5
|
-
BigDecimal is copyrighted free software by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
|
6
|
-
You can redistribute it and/or modify it under either the terms of the GPL
|
7
|
-
(see COPYING file), or the conditions below:
|
8
|
-
|
9
|
-
1. You may make and give away verbatim copies of the source form of the
|
10
|
-
software without restriction, provided that you duplicate all of the
|
11
|
-
original copyright notices and associated disclaimers.
|
12
|
-
|
13
|
-
2. You may modify your copy of the software in any way, provided that
|
14
|
-
you do at least ONE of the following:
|
15
|
-
|
16
|
-
a) place your modifications in the Public Domain or otherwise
|
17
|
-
make them Freely Available, such as by posting said
|
18
|
-
modifications to Usenet or an equivalent medium, or by allowing
|
19
|
-
the author to include your modifications in the software.
|
20
|
-
|
21
|
-
b) use the modified software only within your corporation or
|
22
|
-
organization.
|
23
|
-
|
24
|
-
c) rename any non-standard executables so the names do not conflict
|
25
|
-
with standard executables, which must also be provided.
|
26
|
-
|
27
|
-
d) make other distribution arrangements with the author.
|
28
|
-
|
29
|
-
3. You may distribute the software in object code or executable
|
30
|
-
form, provided that you do at least ONE of the following:
|
31
|
-
|
32
|
-
a) distribute the executables and library files of the software,
|
33
|
-
together with instructions (in the manual page or equivalent)
|
34
|
-
on where to get the original distribution.
|
35
|
-
|
36
|
-
b) accompany the distribution with the machine-readable source of
|
37
|
-
the software.
|
38
|
-
|
39
|
-
c) give non-standard executables non-standard names, with
|
40
|
-
instructions on where to get the original software distribution.
|
41
|
-
|
42
|
-
d) make other distribution arrangements with the author.
|
43
|
-
|
44
|
-
4. You may modify and include the part of the software into any other
|
45
|
-
software (possibly commercial).
|
46
|
-
|
47
|
-
5. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
48
|
-
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
49
|
-
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
50
|
-
PURPOSE.
|
51
|
-
|
52
|
-
* The Author
|
53
|
-
|
54
|
-
Feel free to send comments and bug reports to the ruby-core team.
|
55
|
-
|
56
|
-
http://bugs.ruby-lang.org
|
57
|
-
|
58
|
-
-------------------------------------------------------
|
59
|
-
created at: Thu Dec 22 1999
|
60
|
-
updated at: Wed Sep 28 2011
|
data/extconf.rb
DELETED