bigdecimal 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +6 -14
  2. data/bigdecimal.c +26 -31
  3. data/bigdecimal.gemspec +1 -1
  4. data/bigdecimal.h +31 -0
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmU5NmUxNTE1ZWZmYjAwYWIxZTIwZmZhY2U1MDg0NGEyZGI4ZmMzMg==
5
- data.tar.gz: !binary |-
6
- MDM3MGUwYjdlYjMyZTMwODY1ZTg2MDI3NDY1ZWY0ZjU5OTIyMTBkOQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NGZlZDI2ZjAzMGRiYzYyMzA3OTFlNjk1M2ZmZjU2NmE5NmQyNDFlY2M2Zjk3
10
- OWUwNTU5MWI4MDg0YWZhYTZjZWU3OGEzMjU1NzI4YzE5ZDk1MmJjNDI5ZTEy
11
- NjVhMGY0NWU3NGE1MzFiNGRkMGMwYmI3NDZjNmYyMjY5MjgwMmY=
12
- data.tar.gz: !binary |-
13
- YzM3MDZmZTkwYjNlNTcxMGRiN2UwNjY1NmNjMDYxY2M1Y2ZjNzk0MjQ2ZTlj
14
- ODhjMjVkZDAyNDMwYWZmYTMzYjk4ZmU3OWVjMTIwYzUwMDU2MWVkZmFlYWIw
15
- ZGJmMjIzM2QyNjUzYjlkOTUyYzBiZDBkNTIxMThhNzZiYjY1ZDA=
2
+ SHA1:
3
+ metadata.gz: ea6ac110b94c2c87c1edad365c8f07966d1f43d6
4
+ data.tar.gz: 5c3f0712afa20b5dc28dd150af767ccaebf1fe2f
5
+ SHA512:
6
+ metadata.gz: 3602737a5ef698b032a9d749791abba58ea73d77ce8b7e8b484c4b79588e2b5fe5388a084101e63b67646c81dd7e4c6bd2d1d5691d5c0db737bc6be122fb1981
7
+ data.tar.gz: 280962bae9dbe5e7bdb3edb38d53e16e9dc449fa27c3156062145d2612f4e2ffecdd91ec496e77e07da4dcd647ad4bad7c6d9b86675eebf3b71e0068d7323ed6
@@ -86,23 +86,9 @@ static ID id_eq;
86
86
  #endif
87
87
 
88
88
  #ifndef RBIGNUM_ZERO_P
89
- # define RBIGNUM_ZERO_P(x) (RBIGNUM_LEN(x) == 0 || \
90
- (RBIGNUM_DIGITS(x)[0] == 0 && \
91
- (RBIGNUM_LEN(x) == 1 || bigzero_p(x))))
89
+ # define RBIGNUM_ZERO_P(x) rb_bigzero_p(x)
92
90
  #endif
93
91
 
94
- static inline int
95
- bigzero_p(VALUE x)
96
- {
97
- long i;
98
- BDIGIT *ds = RBIGNUM_DIGITS(x);
99
-
100
- for (i = RBIGNUM_LEN(x) - 1; 0 <= i; i--) {
101
- if (ds[i]) return 0;
102
- }
103
- return 1;
104
- }
105
-
106
92
  #ifndef RRATIONAL_ZERO_P
107
93
  # define RRATIONAL_ZERO_P(x) (FIXNUM_P(RRATIONAL(x)->num) && \
108
94
  FIX2LONG(RRATIONAL(x)->num) == 0)
@@ -2130,7 +2116,11 @@ is_even(VALUE x)
2130
2116
  return (FIX2LONG(x) % 2) == 0;
2131
2117
 
2132
2118
  case T_BIGNUM:
2133
- return (RBIGNUM_DIGITS(x)[0] % 2) == 0;
2119
+ {
2120
+ unsigned long l;
2121
+ rb_big_pack(x, &l, 1);
2122
+ return l % 2 == 0;
2123
+ }
2134
2124
 
2135
2125
  default:
2136
2126
  break;
@@ -2608,7 +2598,7 @@ BigDecimal_save_exception_mode(VALUE self)
2608
2598
  *
2609
2599
  * Execute the provided block, but preserve the rounding mode
2610
2600
  *
2611
- * BigDecimal.save_exception_mode do
2601
+ * BigDecimal.save_rounding_mode do
2612
2602
  * BigDecimal.mode(BigDecimal::ROUND_MODE, :up)
2613
2603
  * puts BigDecimal.mode(BigDecimal::ROUND_MODE)
2614
2604
  * end
@@ -2735,7 +2725,7 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
2735
2725
  else if (vx == NULL) {
2736
2726
  cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
2737
2727
  }
2738
- RB_GC_GUARD(vx->obj);
2728
+ x = RB_GC_GUARD(vx->obj);
2739
2729
 
2740
2730
  n = prec + rmpd_double_figures();
2741
2731
  negative = VpGetSign(vx) < 0;
@@ -2948,15 +2938,7 @@ get_vp_value:
2948
2938
  /* Document-class: BigDecimal
2949
2939
  * BigDecimal provides arbitrary-precision floating point decimal arithmetic.
2950
2940
  *
2951
- * Copyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
2952
- *
2953
- * You may distribute under the terms of either the GNU General Public
2954
- * License or the Artistic License, as specified in the README file
2955
- * of the BigDecimal distribution.
2956
- *
2957
- * Documented by mathew <meta@pobox.com>.
2958
- *
2959
- * = Introduction
2941
+ * == Introduction
2960
2942
  *
2961
2943
  * Ruby provides built-in support for arbitrary precision integer arithmetic.
2962
2944
  *
@@ -2996,12 +2978,12 @@ get_vp_value:
2996
2978
  *
2997
2979
  * (1.2 - 1.0) == 0.2 #=> false
2998
2980
  *
2999
- * = Special features of accurate decimal arithmetic
2981
+ * == Special features of accurate decimal arithmetic
3000
2982
  *
3001
2983
  * Because BigDecimal is more accurate than normal binary floating point
3002
2984
  * arithmetic, it requires some special values.
3003
2985
  *
3004
- * == Infinity
2986
+ * === Infinity
3005
2987
  *
3006
2988
  * BigDecimal sometimes needs to return infinity, for example if you divide
3007
2989
  * a value by zero.
@@ -3013,7 +2995,7 @@ get_vp_value:
3013
2995
  * <code>'Infinity'</code>, <code>'+Infinity'</code> and
3014
2996
  * <code>'-Infinity'</code> (case-sensitive)
3015
2997
  *
3016
- * == Not a Number
2998
+ * === Not a Number
3017
2999
  *
3018
3000
  * When a computation results in an undefined value, the special value +NaN+
3019
3001
  * (for 'not a number') is returned.
@@ -3030,7 +3012,7 @@ get_vp_value:
3030
3012
  * n == 0.0 #=> nil
3031
3013
  * n == n #=> nil
3032
3014
  *
3033
- * == Positive and negative zero
3015
+ * === Positive and negative zero
3034
3016
  *
3035
3017
  * If a computation results in a value which is too small to be represented as
3036
3018
  * a BigDecimal within the currently specified limits of precision, zero must
@@ -3052,6 +3034,19 @@ get_vp_value:
3052
3034
  *
3053
3035
  * Note also that in mathematics, there is no particular concept of negative
3054
3036
  * or positive zero; true mathematical zero has no sign.
3037
+ *
3038
+ * == License
3039
+ *
3040
+ * Copyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
3041
+ *
3042
+ * You may distribute under the terms of either the GNU General Public
3043
+ * License or the Artistic License, as specified in the README file
3044
+ * of the BigDecimal distribution.
3045
+ *
3046
+ * Maintained by mrkn <mrkn@mrkn.jp> and ruby-core members.
3047
+ *
3048
+ * Documented by zzak <zachary@zacharyscott.net>, mathew <meta@pobox.com>, and
3049
+ * many other contributors.
3055
3050
  */
3056
3051
  void
3057
3052
  Init_bigdecimal(void)
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- _VERSION = "1.2.0"
2
+ _VERSION = "1.2.1"
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "bigdecimal"
@@ -19,6 +19,37 @@
19
19
  #include "ruby/ruby.h"
20
20
  #include <float.h>
21
21
 
22
+ #ifndef RB_UNUSED_VAR
23
+ # ifdef __GNUC__
24
+ # define RB_UNUSED_VAR(x) x __attribute__ ((unused))
25
+ # else
26
+ # define RB_UNUSED_VAR(x) x
27
+ # endif
28
+ #endif
29
+
30
+ #ifndef UNREACHABLE
31
+ # define UNREACHABLE /* unreachable */
32
+ #endif
33
+
34
+ #undef BDIGIT
35
+ #undef SIZEOF_BDIGITS
36
+ #undef BDIGIT_DBL
37
+ #undef BDIGIT_DBL_SIGNED
38
+ #undef PRI_BDIGIT_PREFIX
39
+ #undef PRI_BDIGIT_DBL_PREFIX
40
+
41
+ #ifdef HAVE_INT64_T
42
+ # define BDIGIT uint32_t
43
+ # define BDIGIT_DBL uint64_t
44
+ # define BDIGIT_DBL_SIGNED int64_t
45
+ # define SIZEOF_BDIGITS 4
46
+ #else
47
+ # define BDIGIT uint16_t
48
+ # define BDIGIT_DBL uint32_t
49
+ # define BDIGIT_DBL_SIGNED int32_t
50
+ # define SIZEOF_BDIGITS 2
51
+ #endif
52
+
22
53
  #if defined(__cplusplus)
23
54
  extern "C" {
24
55
  #if 0
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
@@ -43,17 +43,17 @@ require_paths:
43
43
  - .
44
44
  required_ruby_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ! '>='
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ! '>='
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
55
  rubyforge_project:
56
- rubygems_version: 2.0.3
56
+ rubygems_version: 2.0.2
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: Arbitrary-precision decimal floating-point number library.