diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-14 05:42:48 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-14 05:42:48 +0000 |
commit | 512b9875444fef706597d2447b9e52d8ae1c09f7 (patch) | |
tree | 34b2877a5465e5426649bb8eb12cd33fbaf247d7 /ext | |
parent | 62e67609b694000cfdb5b80152d3c48a90cfb79b (diff) | |
download | ruby-512b9875444fef706597d2447b9e52d8ae1c09f7.tar.gz |
* ext/bigdecimal/bigdecimal.c: use `RB_TYPE_P(x, t)` instead of
`TYPE(x) == t`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index dca54b44db..af4b555b65 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -674,7 +674,7 @@ BigDecimal_to_i(VALUE self) ret = rb_funcall(numerator, '*', 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(dpower))); - if (TYPE(ret) == T_FLOAT) + if (RB_TYPE_P(ret, T_FLOAT)) rb_raise(rb_eFloatDomainError, "Infinity"); return ret; } @@ -784,11 +784,11 @@ BigDecimal_coerce(VALUE self, VALUE other) VALUE obj; Real *b; - if (TYPE(other) == T_FLOAT) { + if (RB_TYPE_P(other, T_FLOAT)) { obj = rb_assoc_new(other, BigDecimal_to_f(self)); } else { - if (TYPE(other) == T_RATIONAL) { + if (RB_TYPE_P(other, T_RATIONAL)) { Real* pv = DATA_PTR(self); GUARD_OBJ(b, GetVpValueWithPrec(other, pv->Prec*VpBaseFig(), 1)); } @@ -840,10 +840,10 @@ BigDecimal_add(VALUE self, VALUE r) size_t mx; GUARD_OBJ(a, GetVpValue(self, 1)); - if (TYPE(r) == T_FLOAT) { + if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, DBL_DIG+1, 1); } - else if (TYPE(r) == T_RATIONAL) { + else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { @@ -894,10 +894,10 @@ BigDecimal_sub(VALUE self, VALUE r) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - if (TYPE(r) == T_FLOAT) { + if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, DBL_DIG+1, 1); } - else if (TYPE(r) == T_RATIONAL) { + else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { @@ -1155,10 +1155,10 @@ BigDecimal_mult(VALUE self, VALUE r) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - if (TYPE(r) == T_FLOAT) { + if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, DBL_DIG+1, 1); } - else if (TYPE(r) == T_RATIONAL) { + else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { @@ -1183,10 +1183,10 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - if (TYPE(r) == T_FLOAT) { + if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, DBL_DIG+1, 1); } - else if (TYPE(r) == T_RATIONAL) { + else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { @@ -1258,10 +1258,10 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - if (TYPE(r) == T_FLOAT) { + if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, DBL_DIG+1, 1); } - else if (TYPE(r) == T_RATIONAL) { + else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { @@ -1359,10 +1359,10 @@ BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv) Real *f=NULL; GUARD_OBJ(a,GetVpValue(self,1)); - if (TYPE(r) == T_FLOAT) { + if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, DBL_DIG+1, 1); } - else if (TYPE(r) == T_RATIONAL) { + else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { @@ -1852,7 +1852,7 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self) GUARD_OBJ(vp,GetVpValue(self,1)); if(rb_scan_args(argc,argv,"01",&f)==1) { - if(TYPE(f)==T_STRING) { + if (RB_TYPE_P(f, T_STRING)) { SafeStringValue(f); psz = RSTRING_PTR(f); if(*psz==' ') { @@ -2003,7 +2003,7 @@ static VALUE BigMath_s_log(VALUE, VALUE, VALUE); inline static int is_integer(VALUE x) { - return (TYPE(x) == T_FIXNUM || TYPE(x) == T_BIGNUM); + return (RB_TYPE_P(x, T_FIXNUM) || RB_TYPE_P(x, T_BIGNUM)); } inline static int @@ -2012,10 +2012,10 @@ is_negative(VALUE x) if (FIXNUM_P(x)) { return FIX2LONG(x) < 0; } - else if (TYPE(x) == T_BIGNUM) { + else if (RB_TYPE_P(x, T_BIGNUM)) { return RBIGNUM_NEGATIVE_P(x); } - else if (TYPE(x) == T_FLOAT) { + else if (RB_TYPE_P(x, T_FLOAT)) { return RFLOAT_VALUE(x) < 0.0; } return RTEST(rb_funcall(x, '<', 1, INT2FIX(0))); @@ -2278,7 +2278,7 @@ retry: if (exp != NULL) { return rmpd_power_by_big_decimal(x, exp, n); } - else if (TYPE(vexp) == T_BIGNUM) { + else if (RB_TYPE_P(vexp, T_BIGNUM)) { VALUE abs_value = BigDecimal_abs(self); if (is_one(abs_value)) { return ToValue(VpCreateRbObject(n, "1")); @@ -2752,7 +2752,7 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) double flo; long fix; - if (TYPE(vprec) != T_FIXNUM && TYPE(vprec) != T_BIGNUM) { + if (!is_integer(vprec)) { rb_raise(rb_eArgError, "precision must be an Integer"); } |