mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (rb_big_cmp): raise for NaN. (ruby-bugs-ja:PR#284).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
91d884b86e
commit
66f8f8691b
2 changed files with 10 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Aug 12 16:15:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* bignum.c (rb_big_cmp): raise for NaN. (ruby-bugs-ja:PR#284).
|
||||
|
||||
Sun Aug 11 09:34:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* eval.c (rb_eval): set line number from all nodes.
|
||||
|
|
11
bignum.c
11
bignum.c
|
@ -77,7 +77,7 @@ get2comp(x, carry) /* get 2's complement */
|
|||
} while (i < RBIGNUM(x)->len);
|
||||
if (!carry) return;
|
||||
if ((ds[RBIGNUM(x)->len-1] & (1<<(BITSPERDIG-1))) == 0) {
|
||||
REALLOC_N(RBIGNUM(x)->digits, BDIGIT, RBIGNUM(x)->len++);
|
||||
REALLOC_N(RBIGNUM(x)->digits, BDIGIT, ++RBIGNUM(x)->len);
|
||||
ds = BDIGITS(x);
|
||||
ds[RBIGNUM(x)->len-1] = ~0;
|
||||
}
|
||||
|
@ -826,11 +826,12 @@ rb_big_cmp(x, y)
|
|||
|
||||
case T_FLOAT:
|
||||
{
|
||||
double d = rb_big2dbl(x);
|
||||
double d = rb_big2dbl(x);
|
||||
|
||||
if (d == RFLOAT(y)->value) return INT2FIX(0);
|
||||
if (d > RFLOAT(y)->value) return INT2FIX(1);
|
||||
if (d < RFLOAT(y)->value) return INT2FIX(-1);
|
||||
if (d == RFLOAT(y)->value) return INT2FIX(0);
|
||||
if (d > RFLOAT(y)->value) return INT2FIX(1);
|
||||
if (d < RFLOAT(y)->value) return INT2FIX(-1);
|
||||
rb_raise(rb_eFloatDomainError, "comparing NaN");
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue