diff --git a/ChangeLog b/ChangeLog index ebab6a63a0..4930538324 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Aug 12 16:15:37 2002 Nobuyoshi Nakada + + * bignum.c (rb_big_cmp): raise for NaN. (ruby-bugs-ja:PR#284). + Sun Aug 11 09:34:07 2002 Nobuyoshi Nakada * eval.c (rb_eval): set line number from all nodes. diff --git a/bignum.c b/bignum.c index fbf293de83..26036775e6 100644 --- a/bignum.c +++ b/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;