summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-12 07:21:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-12 07:21:25 +0000
commit66f8f8691b2f63428c2e0fbf95f794443ce89e18 (patch)
tree9f36b575095d48a4880718c606a864eebc6a509f /bignum.c
parent91d884b86e3cd51962360eea8db2307c0ad61678 (diff)
* 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
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/bignum.c b/bignum.c
index fbf293d..2603677 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;