* bignum.c (rb_big_divide), numeric.c (fix_divide): check for result
domain. [ruby-dev:34559] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
582983c224
commit
b5f2df6b9e
@ -1,3 +1,8 @@
|
|||||||
|
Thu May 1 23:59:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* bignum.c (rb_big_divide), numeric.c (fix_divide): check for result
|
||||||
|
domain. [ruby-dev:34559]
|
||||||
|
|
||||||
Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* range.c (range_step): check if step can be converted to an integer.
|
* range.c (range_step): check if step can be converted to an integer.
|
||||||
|
2
bignum.c
2
bignum.c
@ -1821,7 +1821,7 @@ rb_big_divide(VALUE x, VALUE y, ID op)
|
|||||||
return DOUBLE2NUM(div);
|
return DOUBLE2NUM(div);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return LONG2NUM((long)div);
|
return rb_dbl2big(div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
numeric.c
22
numeric.c
@ -2249,7 +2249,7 @@ fix_fdiv(VALUE x, VALUE y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fix_divide(VALUE x, VALUE y, int flo)
|
fix_divide(VALUE x, VALUE y, ID op)
|
||||||
{
|
{
|
||||||
if (FIXNUM_P(y)) {
|
if (FIXNUM_P(y)) {
|
||||||
long div;
|
long div;
|
||||||
@ -2262,15 +2262,17 @@ fix_divide(VALUE x, VALUE y, int flo)
|
|||||||
x = rb_int2big(FIX2LONG(x));
|
x = rb_int2big(FIX2LONG(x));
|
||||||
return rb_big_div(x, y);
|
return rb_big_div(x, y);
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
if (flo) {
|
{
|
||||||
return DOUBLE2NUM((double)FIX2LONG(x) / RFLOAT_VALUE(y));
|
double div = (double)FIX2LONG(x) / RFLOAT_VALUE(y);
|
||||||
}
|
if (op == '/') {
|
||||||
else {
|
return DOUBLE2NUM(div);
|
||||||
long div = (double)FIX2LONG(x) / RFLOAT_VALUE(y);
|
}
|
||||||
return LONG2NUM(div);
|
else {
|
||||||
|
return rb_dbl2big(div);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return rb_num_coerce_bin(x, y, flo ? '/' : rb_intern("div"));
|
return rb_num_coerce_bin(x, y, op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2286,7 +2288,7 @@ fix_divide(VALUE x, VALUE y, int flo)
|
|||||||
static VALUE
|
static VALUE
|
||||||
fix_div(VALUE x, VALUE y)
|
fix_div(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
return fix_divide(x, y, Qtrue);
|
return fix_divide(x, y, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2299,7 +2301,7 @@ fix_div(VALUE x, VALUE y)
|
|||||||
static VALUE
|
static VALUE
|
||||||
fix_idiv(VALUE x, VALUE y)
|
fix_idiv(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
return fix_divide(x, y, Qfalse);
|
return fix_divide(x, y, rb_intern("div"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user