* numeric.c: Simplify [ruby-core:61106] [Bug #9570]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2014-02-28 02:03:30 +00:00
Родитель debb5e4cb7
Коммит e184e31c09
1 изменённых файлов: 9 добавлений и 13 удалений

Просмотреть файл

@ -1805,26 +1805,22 @@ VALUE
ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl)
{
if (FIXNUM_P(from) && FIXNUM_P(to) && FIXNUM_P(step)) {
long delta, diff, result;
long delta, diff;
diff = FIX2LONG(step);
if (!diff) rb_num_zerodiv();
delta = FIX2LONG(to) - FIX2LONG(from);
if (diff < 0) {
diff = -diff;
delta = -delta;
}
if (excl) {
delta += (diff > 0 ? -1 : +1);
delta--;
}
if (delta) {
if (diff < 0) {
if (delta > 0) return INT2FIX(0);
diff = -diff;
delta = -delta;
}
else {
if (delta < 0) return INT2FIX(0);
}
if (delta < 0) {
return INT2FIX(0);
}
result = delta / diff;
return LONG2FIX(result >= 0 ? result + 1 : 0);
return LONG2FIX(delta / diff + 1);
}
else if (RB_TYPE_P(from, T_FLOAT) || RB_TYPE_P(to, T_FLOAT) || RB_TYPE_P(step, T_FLOAT)) {
double n = ruby_float_step_size(NUM2DBL(from), NUM2DBL(to), NUM2DBL(step), excl);