1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* numeric.c (fix_div): should not convert the result into

integer.  [ruby-core:05524]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2005-08-04 04:31:33 +00:00
parent a767a76ad1
commit 53b4c2b87a
4 changed files with 32 additions and 6 deletions

View file

@ -1,3 +1,8 @@
Thu Aug 4 13:30:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (fix_div): should not convert the result into
integer. [ruby-core:05524]
Thu Aug 4 08:03:39 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): should not modify $mflags for each

View file

@ -2155,7 +2155,7 @@ fix_div(x, y)
x = rb_int2big(FIX2LONG(x));
return rb_big_div(x, y);
case T_FLOAT:
return rb_Integer(rb_float_new((double)FIX2LONG(x) / RFLOAT(y)->value));
return rb_float_new((double)FIX2LONG(x) / RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}

View file

@ -2093,6 +2093,18 @@ rb_to_integer(val, method)
return v;
}
VALUE
rb_check_to_integer(val, method)
VALUE val;
char *method;
{
VALUE v = convert_type(val, "Integer", method, Qfalse);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
return Qnil;
}
return v;
}
VALUE
rb_to_int(val)
VALUE val;

19
range.c
View file

@ -466,12 +466,21 @@ rb_range_beg_len(range, begp, lenp, len, err)
long len;
int err;
{
long beg, end, b, e;
VALUE b, e;
long beg, end;
if (!rb_obj_is_kind_of(range, rb_cRange)) return Qfalse;
beg = b = NUM2LONG(rb_ivar_get(range, id_beg));
end = e = NUM2LONG(rb_ivar_get(range, id_end));
if (rb_obj_is_kind_of(range, rb_cRange)) {
b = rb_ivar_get(range, id_beg);
e = rb_ivar_get(range, id_end);
}
else {
b = rb_check_to_integer(range, "begin");
if (NIL_P(b)) return Qnil;
e = rb_check_to_integer(range, "end");
if (NIL_P(e)) return Qnil;
}
beg = NUM2LONG(b);
end = NUM2LONG(e);
if (beg < 0) {
beg += len;