From 5e9b7bacc3731b909ea6341d7158ef6b34e09f2d Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 12 Jan 2014 00:21:37 +0000 Subject: 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 --- include/ruby/util.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/ruby') diff --git a/include/ruby/util.h b/include/ruby/util.h index 5be5f2e0b4..8443af74d9 100644 --- a/include/ruby/util.h +++ b/include/ruby/util.h @@ -47,6 +47,9 @@ extern "C" { RUBY_SYMBOL_EXPORT_BEGIN +#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999) +/* an approximation of ceil(n * log10(2)), upto 65536 at least */ + #define scan_oct(s,l,e) ((int)ruby_scan_oct((s),(l),(e))) unsigned long ruby_scan_oct(const char *, size_t, size_t *); #define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e))) -- cgit v1.2.3