ruby-changes:64340
From: Kenta <ko1@a...>
Date: Sat, 19 Dec 2020 22:14:41 +0900 (JST)
Subject: [ruby-changes:64340] 97d4e72e0b (master): [bigdecimal] Use DBLE_FIG
https://git.ruby-lang.org/ruby.git/commit/?id=97d4e72e0b From 97d4e72e0bc4b07442f5ce674a945df91d9fce3c Mon Sep 17 00:00:00 2001 From: Kenta Murata <mrkn@m...> Date: Sat, 19 Dec 2020 01:30:37 +0900 Subject: [bigdecimal] Use DBLE_FIG https://github.com/ruby/bigdecimal/commit/12296dcb90 diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 8875682..9952193 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -77,7 +77,7 @@ static ID id_half; https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L77 #define BASE1 (BASE/10) #ifndef DBLE_FIG -#define DBLE_FIG (DBL_DIG+1) /* figure of double */ +#define DBLE_FIG rmpd_double_figures() /* figure of double */ #endif #ifndef RRATIONAL_ZERO_P @@ -252,7 +252,7 @@ again: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L252 switch(TYPE(v)) { case T_FLOAT: if (prec < 0) goto unable_to_coerce_without_prec; - if (prec > DBL_DIG+1) goto SomeOneMayDoIt; + if (prec > (long)DBLE_FIG) goto SomeOneMayDoIt; d = RFLOAT_VALUE(v); if (!isfinite(d)) { pv = VpCreateRbObject(1, NULL); @@ -899,7 +899,7 @@ BigDecimal_coerce(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L899 Real *b; if (RB_TYPE_P(other, T_FLOAT)) { - GUARD_OBJ(b, GetVpValueWithPrec(other, DBL_DIG+1, 1)); + GUARD_OBJ(b, GetVpValueWithPrec(other, DBLE_FIG, 1)); obj = rb_assoc_new(ToValue(b), self); } else { @@ -957,7 +957,7 @@ BigDecimal_add(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L957 GUARD_OBJ(a, GetVpValue(self, 1)); if (RB_TYPE_P(r, T_FLOAT)) { - b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + b = GetVpValueWithPrec(r, DBLE_FIG, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); @@ -1015,7 +1015,7 @@ BigDecimal_sub(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1015 GUARD_OBJ(a, GetVpValue(self,1)); if (RB_TYPE_P(r, T_FLOAT)) { - b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + b = GetVpValueWithPrec(r, DBLE_FIG, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); @@ -1065,7 +1065,7 @@ BigDecimalCmp(VALUE self, VALUE r,char op) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1065 break; case T_FLOAT: - GUARD_OBJ(b, GetVpValueWithPrec(r, DBL_DIG+1, 0)); + GUARD_OBJ(b, GetVpValueWithPrec(r, DBLE_FIG, 0)); break; case T_RATIONAL: @@ -1306,7 +1306,7 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1306 GUARD_OBJ(a, GetVpValue(self, 1)); if (RB_TYPE_P(r, T_FLOAT)) { - b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + b = GetVpValueWithPrec(r, DBLE_FIG, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); @@ -1372,7 +1372,7 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1372 GUARD_OBJ(a, GetVpValue(self, 1)); if (RB_TYPE_P(r, T_FLOAT)) { - b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + b = GetVpValueWithPrec(r, DBLE_FIG, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); @@ -1473,7 +1473,7 @@ BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1473 GUARD_OBJ(a, GetVpValue(self, 1)); if (RB_TYPE_P(r, T_FLOAT)) { - b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + b = GetVpValueWithPrec(r, DBLE_FIG, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); @@ -2685,7 +2685,7 @@ VpNewVarArg(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2685 VpDtoV(pv, d); return pv; } - if (mf > DBL_DIG+1) { + if (mf > DBLE_FIG) { if (!exc) { return NULL; } @@ -2980,7 +2980,7 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2980 infinite = isinf(flo); nan = isnan(flo); if (!infinite && !nan) { - vx = GetVpValueWithPrec(x, DBL_DIG+1, 0); + vx = GetVpValueWithPrec(x, DBLE_FIG, 0); } break; @@ -3133,7 +3133,7 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3133 infinite = isinf(flo); nan = isnan(flo); if (!zero && !negative && !infinite && !nan) { - vx = GetVpValueWithPrec(x, DBL_DIG+1, 1); + vx = GetVpValueWithPrec(x, DBLE_FIG, 1); } break; @@ -4023,7 +4023,7 @@ VpNumOfChars(Real *vp,const char *pszFmt) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4023 * by one BDIGIT word in the computer used. * * [Returns] - * 1+DBL_DIG ... OK + * DBLE_FIG ... OK */ VP_EXPORT size_t VpInit(BDIGIT BaseVal) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/