bigdecimal 2.0.3 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bigdecimal.gemspec +8 -9
- data/ext/bigdecimal/bigdecimal.c +1555 -787
- data/ext/bigdecimal/bigdecimal.h +67 -170
- data/ext/bigdecimal/bits.h +141 -0
- data/ext/bigdecimal/extconf.rb +38 -4
- data/ext/bigdecimal/feature.h +68 -0
- data/ext/bigdecimal/missing/dtoa.c +3462 -0
- data/ext/bigdecimal/missing.c +27 -0
- data/ext/bigdecimal/missing.h +235 -0
- data/ext/bigdecimal/static_assert.h +54 -0
- data/lib/bigdecimal/util.rb +1 -1
- metadata +11 -61
@@ -0,0 +1,27 @@
|
|
1
|
+
#include <ruby/ruby.h>
|
2
|
+
|
3
|
+
#ifdef HAVE_RUBY_ATOMIC_H
|
4
|
+
# include <ruby/atomic.h>
|
5
|
+
#endif
|
6
|
+
|
7
|
+
#ifdef RUBY_ATOMIC_PTR_CAS
|
8
|
+
# define ATOMIC_PTR_CAS(var, old, new) RUBY_ATOMIC_PTR_CAS(var, old, new)
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
12
|
+
/* GCC warns about unknown sanitizer, which is annoying. */
|
13
|
+
# undef NO_SANITIZE
|
14
|
+
# define NO_SANITIZE(x, y) \
|
15
|
+
_Pragma("GCC diagnostic push") \
|
16
|
+
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
|
17
|
+
__attribute__((__no_sanitize__(x))) y; \
|
18
|
+
_Pragma("GCC diagnostic pop")
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#undef strtod
|
22
|
+
#define strtod BigDecimal_strtod
|
23
|
+
#undef dtoa
|
24
|
+
#define dtoa BigDecimal_dtoa
|
25
|
+
#undef hdtoa
|
26
|
+
#define hdtoa BigDecimal_hdtoa
|
27
|
+
#include "missing/dtoa.c"
|
@@ -0,0 +1,235 @@
|
|
1
|
+
#ifndef MISSING_H
|
2
|
+
#define MISSING_H 1
|
3
|
+
|
4
|
+
#if defined(__cplusplus)
|
5
|
+
extern "C" {
|
6
|
+
#if 0
|
7
|
+
} /* satisfy cc-mode */
|
8
|
+
#endif
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#ifdef HAVE_STDLIB_H
|
12
|
+
# include <stdlib.h>
|
13
|
+
#endif
|
14
|
+
|
15
|
+
#ifdef HAVE_MATH_H
|
16
|
+
# include <math.h>
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#ifndef RB_UNUSED_VAR
|
20
|
+
# if defined(_MSC_VER) && _MSC_VER >= 1911
|
21
|
+
# define RB_UNUSED_VAR(x) x [[maybe_unused]]
|
22
|
+
|
23
|
+
# elif defined(__has_cpp_attribute) && __has_cpp_attribute(maybe_unused)
|
24
|
+
# define RB_UNUSED_VAR(x) x [[maybe_unused]]
|
25
|
+
|
26
|
+
# elif defined(__has_c_attribute) && __has_c_attribute(maybe_unused)
|
27
|
+
# define RB_UNUSED_VAR(x) x [[maybe_unused]]
|
28
|
+
|
29
|
+
# elif defined(__GNUC__)
|
30
|
+
# define RB_UNUSED_VAR(x) x __attribute__ ((unused))
|
31
|
+
|
32
|
+
# else
|
33
|
+
# define RB_UNUSED_VAR(x) x
|
34
|
+
# endif
|
35
|
+
#endif /* RB_UNUSED_VAR */
|
36
|
+
|
37
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1310
|
38
|
+
# define HAVE___ASSUME
|
39
|
+
|
40
|
+
#elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1300
|
41
|
+
# define HAVE___ASSUME
|
42
|
+
#endif
|
43
|
+
|
44
|
+
#ifndef UNREACHABLE
|
45
|
+
# if __has_builtin(__builtin_unreachable)
|
46
|
+
# define UNREACHABLE __builtin_unreachable()
|
47
|
+
|
48
|
+
# elif defined(HAVE___ASSUME)
|
49
|
+
# define UNREACHABLE __assume(0)
|
50
|
+
|
51
|
+
# else
|
52
|
+
# define UNREACHABLE /* unreachable */
|
53
|
+
# endif
|
54
|
+
#endif /* UNREACHABLE */
|
55
|
+
|
56
|
+
/* bool */
|
57
|
+
|
58
|
+
#if defined(__bool_true_false_are_defined)
|
59
|
+
# /* Take that. */
|
60
|
+
|
61
|
+
#elif defined(HAVE_STDBOOL_H)
|
62
|
+
# include <stdbool.h>
|
63
|
+
|
64
|
+
#else
|
65
|
+
typedef unsigned char _Bool;
|
66
|
+
# define bool _Bool
|
67
|
+
# define true ((_Bool)+1)
|
68
|
+
# define false ((_Bool)-1)
|
69
|
+
# define __bool_true_false_are_defined
|
70
|
+
#endif
|
71
|
+
|
72
|
+
/* abs */
|
73
|
+
|
74
|
+
#ifndef HAVE_LABS
|
75
|
+
static inline long
|
76
|
+
labs(long const x)
|
77
|
+
{
|
78
|
+
if (x < 0) return -x;
|
79
|
+
return x;
|
80
|
+
}
|
81
|
+
#endif
|
82
|
+
|
83
|
+
#ifndef HAVE_LLABS
|
84
|
+
static inline LONG_LONG
|
85
|
+
llabs(LONG_LONG const x)
|
86
|
+
{
|
87
|
+
if (x < 0) return -x;
|
88
|
+
return x;
|
89
|
+
}
|
90
|
+
#endif
|
91
|
+
|
92
|
+
#ifdef vabs
|
93
|
+
# undef vabs
|
94
|
+
#endif
|
95
|
+
#if SIZEOF_VALUE <= SIZEOF_INT
|
96
|
+
# define vabs abs
|
97
|
+
#elif SIZEOF_VALUE <= SIZEOF_LONG
|
98
|
+
# define vabs labs
|
99
|
+
#elif SIZEOF_VALUE <= SIZEOF_LONG_LONG
|
100
|
+
# define vabs llabs
|
101
|
+
#endif
|
102
|
+
|
103
|
+
/* finite */
|
104
|
+
|
105
|
+
#ifndef HAVE_FINITE
|
106
|
+
static int
|
107
|
+
finite(double)
|
108
|
+
{
|
109
|
+
return !isnan(n) && !isinf(n);
|
110
|
+
}
|
111
|
+
#endif
|
112
|
+
|
113
|
+
#ifndef isfinite
|
114
|
+
# ifndef HAVE_ISFINITE
|
115
|
+
# define HAVE_ISFINITE 1
|
116
|
+
# define isfinite(x) finite(x)
|
117
|
+
# endif
|
118
|
+
#endif
|
119
|
+
|
120
|
+
/* dtoa */
|
121
|
+
char *BigDecimal_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
|
122
|
+
|
123
|
+
/* rational */
|
124
|
+
|
125
|
+
#ifndef HAVE_RB_RATIONAL_NUM
|
126
|
+
static inline VALUE
|
127
|
+
rb_rational_num(VALUE rat)
|
128
|
+
{
|
129
|
+
#ifdef HAVE_TYPE_STRUCT_RRATIONAL
|
130
|
+
return RRATIONAL(rat)->num;
|
131
|
+
#else
|
132
|
+
return rb_funcall(rat, rb_intern("numerator"), 0);
|
133
|
+
#endif
|
134
|
+
}
|
135
|
+
#endif
|
136
|
+
|
137
|
+
#ifndef HAVE_RB_RATIONAL_DEN
|
138
|
+
static inline VALUE
|
139
|
+
rb_rational_den(VALUE rat)
|
140
|
+
{
|
141
|
+
#ifdef HAVE_TYPE_STRUCT_RRATIONAL
|
142
|
+
return RRATIONAL(rat)->den;
|
143
|
+
#else
|
144
|
+
return rb_funcall(rat, rb_intern("denominator"), 0);
|
145
|
+
#endif
|
146
|
+
}
|
147
|
+
#endif
|
148
|
+
|
149
|
+
/* complex */
|
150
|
+
|
151
|
+
#ifndef HAVE_RB_COMPLEX_REAL
|
152
|
+
static inline VALUE
|
153
|
+
rb_complex_real(VALUE cmp)
|
154
|
+
{
|
155
|
+
#ifdef HAVE_TYPE_STRUCT_RCOMPLEX
|
156
|
+
return RCOMPLEX(cmp)->real;
|
157
|
+
#else
|
158
|
+
return rb_funcall(cmp, rb_intern("real"), 0);
|
159
|
+
#endif
|
160
|
+
}
|
161
|
+
#endif
|
162
|
+
|
163
|
+
#ifndef HAVE_RB_COMPLEX_IMAG
|
164
|
+
static inline VALUE
|
165
|
+
rb_complex_imag(VALUE cmp)
|
166
|
+
{
|
167
|
+
# ifdef HAVE_TYPE_STRUCT_RCOMPLEX
|
168
|
+
return RCOMPLEX(cmp)->imag;
|
169
|
+
# else
|
170
|
+
return rb_funcall(cmp, rb_intern("imag"), 0);
|
171
|
+
# endif
|
172
|
+
}
|
173
|
+
#endif
|
174
|
+
|
175
|
+
/* array */
|
176
|
+
|
177
|
+
#ifndef FIX_CONST_VALUE_PTR
|
178
|
+
# if defined(__fcc__) || defined(__fcc_version) || \
|
179
|
+
defined(__FCC__) || defined(__FCC_VERSION)
|
180
|
+
/* workaround for old version of Fujitsu C Compiler (fcc) */
|
181
|
+
# define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
|
182
|
+
# else
|
183
|
+
# define FIX_CONST_VALUE_PTR(x) (x)
|
184
|
+
# endif
|
185
|
+
#endif
|
186
|
+
|
187
|
+
#ifndef HAVE_RB_ARRAY_CONST_PTR
|
188
|
+
static inline const VALUE *
|
189
|
+
rb_array_const_ptr(VALUE a)
|
190
|
+
{
|
191
|
+
return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
|
192
|
+
RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
|
193
|
+
}
|
194
|
+
#endif
|
195
|
+
|
196
|
+
#ifndef RARRAY_CONST_PTR
|
197
|
+
# define RARRAY_CONST_PTR(a) rb_array_const_ptr(a)
|
198
|
+
#endif
|
199
|
+
|
200
|
+
#ifndef RARRAY_AREF
|
201
|
+
# define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i])
|
202
|
+
#endif
|
203
|
+
|
204
|
+
/* symbol */
|
205
|
+
|
206
|
+
#ifndef HAVE_RB_SYM2STR
|
207
|
+
static inline VALUE
|
208
|
+
rb_sym2str(VALUE sym)
|
209
|
+
{
|
210
|
+
return rb_id2str(SYM2ID(sym));
|
211
|
+
}
|
212
|
+
#endif
|
213
|
+
|
214
|
+
/* st */
|
215
|
+
|
216
|
+
#ifndef ST2FIX
|
217
|
+
# undef RB_ST2FIX
|
218
|
+
# define RB_ST2FIX(h) LONG2FIX((long)(h))
|
219
|
+
# define ST2FIX(h) RB_ST2FIX(h)
|
220
|
+
#endif
|
221
|
+
|
222
|
+
/* warning */
|
223
|
+
|
224
|
+
#if !defined(HAVE_RB_CATEGORY_WARN) || !defined(HAVE_CONST_RB_WARN_CATEGORY_DEPRECATED)
|
225
|
+
# define rb_category_warn(category, ...) rb_warn(__VA_ARGS__)
|
226
|
+
#endif
|
227
|
+
|
228
|
+
#if defined(__cplusplus)
|
229
|
+
#if 0
|
230
|
+
{ /* satisfy cc-mode */
|
231
|
+
#endif
|
232
|
+
} /* extern "C" { */
|
233
|
+
#endif
|
234
|
+
|
235
|
+
#endif /* MISSING_H */
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#ifndef BIGDECIMAL_STATIC_ASSERT_H
|
2
|
+
#define BIGDECIMAL_STATIC_ASSERT_H
|
3
|
+
|
4
|
+
#include "feature.h"
|
5
|
+
|
6
|
+
#ifdef HAVE_RUBY_INTERNAL_STATIC_ASSERT_H
|
7
|
+
# include <ruby/internal/static_assert.h>
|
8
|
+
#endif
|
9
|
+
|
10
|
+
#ifdef RBIMPL_STATIC_ASSERT
|
11
|
+
# define STATIC_ASSERT RBIMPL_STATIC_ASSERT
|
12
|
+
#endif
|
13
|
+
|
14
|
+
#ifndef STATIC_ASSERT
|
15
|
+
# /* The following section is copied from CRuby's static_assert.h */
|
16
|
+
|
17
|
+
# if defined(__cplusplus) && defined(__cpp_static_assert)
|
18
|
+
# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
|
19
|
+
# define BIGDECIMAL_STATIC_ASSERT0 static_assert
|
20
|
+
|
21
|
+
# elif defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER >= 1600
|
22
|
+
# define BIGDECIMAL_STATIC_ASSERT0 static_assert
|
23
|
+
|
24
|
+
# elif defined(__INTEL_CXX11_MODE__)
|
25
|
+
# define BIGDECIMAL_STATIC_ASSERT0 static_assert
|
26
|
+
|
27
|
+
# elif defined(__cplusplus) && __cplusplus >= 201103L
|
28
|
+
# define BIGDECIMAL_STATIC_ASSERT0 static_assert
|
29
|
+
|
30
|
+
# elif defined(__cplusplus) && __has_extension(cxx_static_assert)
|
31
|
+
# define BIGDECIMAL_STATIC_ASSERT0 __extension__ static_assert
|
32
|
+
|
33
|
+
# elif defined(__STDC_VERSION__) && __has_extension(c_static_assert)
|
34
|
+
# define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert
|
35
|
+
|
36
|
+
# elif defined(__STDC_VERSION__) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
|
37
|
+
# define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert
|
38
|
+
#endif
|
39
|
+
|
40
|
+
# if defined(__DOXYGEN__)
|
41
|
+
# define STATIC_ASSERT static_assert
|
42
|
+
|
43
|
+
# elif defined(BIGDECIMAL_STATIC_ASSERT0)
|
44
|
+
# define STATIC_ASSERT(name, expr) \
|
45
|
+
BIGDECIMAL_STATIC_ASSERT0(expr, #name ": " #expr)
|
46
|
+
|
47
|
+
# else
|
48
|
+
# define STATIC_ASSERT(name, expr) \
|
49
|
+
typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
|
50
|
+
# endif
|
51
|
+
#endif /* STATIC_ASSERT */
|
52
|
+
|
53
|
+
|
54
|
+
#endif /* BIGDECIMAL_STATIC_ASSERT_H */
|
data/lib/bigdecimal/util.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:
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Murata
|
@@ -10,64 +10,8 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
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: 12.3.3
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: 12.3.3
|
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: 5.0.0
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - "<"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 5.0.0
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: pry
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0'
|
13
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
71
15
|
description: This library provides arbitrary-precision decimal floating-point number
|
72
16
|
class.
|
73
17
|
email:
|
@@ -80,7 +24,13 @@ files:
|
|
80
24
|
- bigdecimal.gemspec
|
81
25
|
- ext/bigdecimal/bigdecimal.c
|
82
26
|
- ext/bigdecimal/bigdecimal.h
|
27
|
+
- ext/bigdecimal/bits.h
|
83
28
|
- ext/bigdecimal/extconf.rb
|
29
|
+
- ext/bigdecimal/feature.h
|
30
|
+
- ext/bigdecimal/missing.c
|
31
|
+
- ext/bigdecimal/missing.h
|
32
|
+
- ext/bigdecimal/missing/dtoa.c
|
33
|
+
- ext/bigdecimal/static_assert.h
|
84
34
|
- lib/bigdecimal.rb
|
85
35
|
- lib/bigdecimal/jacobian.rb
|
86
36
|
- lib/bigdecimal/ludcmp.rb
|
@@ -102,14 +52,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
52
|
requirements:
|
103
53
|
- - ">="
|
104
54
|
- !ruby/object:Gem::Version
|
105
|
-
version: 2.
|
55
|
+
version: 2.5.0
|
106
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
57
|
requirements:
|
108
58
|
- - ">="
|
109
59
|
- !ruby/object:Gem::Version
|
110
60
|
version: '0'
|
111
61
|
requirements: []
|
112
|
-
rubygems_version: 3.2.
|
62
|
+
rubygems_version: 3.2.23
|
113
63
|
signing_key:
|
114
64
|
specification_version: 4
|
115
65
|
summary: Arbitrary-precision decimal floating-point number library.
|