* bignum.c (rb_big_eq): never equal to infinity.

[ruby-core:31603]

* rational.c (nurat_div): hack for integral float divisor.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-08-03 11:30:19 +00:00
Родитель b5dc2576cc
Коммит 292c39098d
4 изменённых файлов: 26 добавлений и 1 удалений

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

@ -1,3 +1,10 @@
Tue Aug 3 20:30:16 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_eq): never equal to infinity.
[ruby-core:31603]
* rational.c (nurat_div): hack for integral float divisor.
Tue Aug 3 14:42:12 2010 NARUSE, Yui <naruse@ruby-lang.org>
* ext/mkext.rb: remove purelib, fixes a bug in r28440, r28441.

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

@ -1567,7 +1567,7 @@ rb_big_eq(VALUE x, VALUE y)
volatile double a, b;
a = RFLOAT_VALUE(y);
if (isnan(a)) return Qfalse;
if (isnan(a) || isinf(a)) return Qfalse;
b = rb_big2dbl(x);
return (a == b)?Qtrue:Qfalse;
}

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

@ -869,6 +869,23 @@ nurat_div(VALUE self, VALUE other)
other, ONE, '/');
}
case T_FLOAT:
{
double x = RFLOAT_VALUE(other), den;
get_dat1(self);
if (isnan(x)) return DBL2NUM(NAN);
if (isinf(x)) {
if (RTEST(f_negative_p(dat->num)) == (x < 0)) {
return DBL2NUM(INFINITY);
}
else {
return DBL2NUM(-INFINITY);
}
}
if (modf(x, &den) == 0.0) {
return rb_rational_raw2(dat->num, f_mul(rb_dbl2big(den), dat->den));
}
}
return rb_funcall(f_to_f(self), '/', 1, other);
case T_RATIONAL:
if (f_zero_p(other))

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

@ -193,6 +193,7 @@ class TestBignum < Test::Unit::TestCase
assert(T31P != 1)
assert(T31P == 2147483647.0)
assert(T31P != "foo")
assert(2**77889 != (1.0/0.0), '[ruby-core:31603]')
end
def test_eql