diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-12 00:21:37 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-12 00:21:37 +0000 |
commit | 5e9b7bacc3731b909ea6341d7158ef6b34e09f2d (patch) | |
tree | 13de30bb8713467ef344ade2c58ed34afe4baa0e /ext/bigdecimal | |
parent | 0e9cad9a8e25282be170d3e4240bd2ba6ce1a419 (diff) | |
download | ruby-5e9b7bacc3731b909ea6341d7158ef6b34e09f2d.tar.gz |
ruby/util.h: DECIMAL_SIZE_OF_BITS
* include/ruby/util.h (DECIMAL_SIZE_OF_BITS): a preprocessor
constant macro to approximate decimal representation size of n-bits
integer.
* iseq.c (register_label): use DECIMAL_SIZE_OF_BITS for better
approximation.
* ext/bigdecimal/bigdecimal.c (BigMath_s_log): ditto.
* common.mk (iseq.o), ext/bigdecimal/depend (bigdecimal.o): add
dependency to ruby/util.h for DECIMAL_SIZE_OF_BITS.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 3 | ||||
-rw-r--r-- | ext/bigdecimal/depend | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index c5a3326fb7..16fba2211f 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -18,6 +18,7 @@ # define BIGDECIMAL_ENABLE_VPRINT 1 #endif #include "bigdecimal.h" +#include "ruby/util.h" #ifndef BIGDECIMAL_DEBUG # define NDEBUG @@ -2919,7 +2920,7 @@ get_vp_value: RB_GC_GUARD(vn) = SSIZET2NUM(n); expo = VpExponent10(vx); if (expo < 0 || expo >= 3) { - char buf[SIZEOF_VALUE * CHAR_BIT / 3 + 4]; + char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4]; snprintf(buf, sizeof(buf), "1E%"PRIdVALUE, -expo); x = BigDecimal_mult2(x, ToValue(VpCreateRbObject(1, buf)), vn); } diff --git a/ext/bigdecimal/depend b/ext/bigdecimal/depend index a68128478c..0a83c1f17f 100644 --- a/ext/bigdecimal/depend +++ b/ext/bigdecimal/depend @@ -1 +1 @@ -bigdecimal.o: bigdecimal.c bigdecimal.h $(HDRS) $(ruby_headers) +bigdecimal.o: bigdecimal.c bigdecimal.h $(HDRS) $(ruby_headers) $(hdrdir)/ruby/util.h |