summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-07 19:04:23 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-07 19:04:23 (GMT)
commite14601527278f8054dadce62dd5e4b65f094bf4e (patch)
treefe526b71fa12cb0c7b1c16fa4cccba5d03ca5c29 /math.c
parentc26293dccfd1ed1388980957c0dd65bdb9c68a01 (diff)
bignum.c, math.c: RB_BIGNUM_TYPE_P
* bignum.c, math.c (RB_BIGNUM_TYPE_P): predicate macro like RB_FLOAT_TYPE_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/math.c b/math.c
index 98282b0..d9c7633 100644
--- a/math.c
+++ b/math.c
@@ -20,6 +20,8 @@
extern int signbit(double);
#endif
+#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
+
VALUE rb_mMath;
VALUE rb_eMathDomainError;
@@ -444,7 +446,7 @@ math_log(int argc, VALUE *argv)
rb_scan_args(argc, argv, "11", &x, &base);
- if (RB_TYPE_P(x, T_BIGNUM) && RBIGNUM_POSITIVE_P(x) &&
+ if (RB_BIGNUM_TYPE_P(x) && RBIGNUM_POSITIVE_P(x) &&
DBL_MAX_EXP <= (numbits = rb_absint_numwords(x, 1, NULL))) {
numbits -= DBL_MANT_DIG;
x = rb_big_rshift(x, SIZET2NUM(numbits));
@@ -501,7 +503,7 @@ math_log2(VALUE obj, VALUE x)
double d0, d;
size_t numbits = 0;
- if (RB_TYPE_P(x, T_BIGNUM) && RBIGNUM_POSITIVE_P(x) &&
+ if (RB_BIGNUM_TYPE_P(x) && RBIGNUM_POSITIVE_P(x) &&
DBL_MAX_EXP <= (numbits = rb_absint_numwords(x, 1, NULL))) {
numbits -= DBL_MANT_DIG;
x = rb_big_rshift(x, SIZET2NUM(numbits));
@@ -540,7 +542,7 @@ math_log10(VALUE obj, VALUE x)
double d0, d;
size_t numbits = 0;
- if (RB_TYPE_P(x, T_BIGNUM) && RBIGNUM_POSITIVE_P(x) &&
+ if (RB_BIGNUM_TYPE_P(x) && RBIGNUM_POSITIVE_P(x) &&
DBL_MAX_EXP <= (numbits = rb_absint_numwords(x, 1, NULL))) {
numbits -= DBL_MANT_DIG;
x = rb_big_rshift(x, SIZET2NUM(numbits));