summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-15 06:13:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-15 06:13:08 +0000
commitc30c3bffe472ee999fc722f63dd1c1984db1d1ce (patch)
treefd5a1cd95ad875ce2768b09c88cecc155dba74b8 /bignum.c
parent35c6e6af5ba2c405a91dc6b9e4af833d0979ed22 (diff)
1.1b9_31
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/bignum.c b/bignum.c
index 94d7095..4318760 100644
--- a/bignum.c
+++ b/bignum.c
@@ -19,7 +19,7 @@ typedef unsigned short USHORT;
#define BITSPERDIG (sizeof(short)*CHAR_BIT)
#define BIGRAD (1L << BITSPERDIG)
#define DIGSPERINT ((unsigned int)(sizeof(long)/sizeof(short)))
-#define BIGUP(x) ((unsigned int)(x) << BITSPERDIG)
+#define BIGUP(x) ((unsigned long)(x) << BITSPERDIG)
#define BIGDN(x) (((x)<0) ? ~((~(x))>>BITSPERDIG) : (x)>>BITSPERDIG)
#define BIGLO(x) ((x) & (BIGRAD-1))
@@ -85,17 +85,17 @@ bignorm(x)
while (len-- && !ds[len]) ;
RBIGNUM(x)->len = ++len;
- if (len*sizeof(USHORT) < sizeof(VALUE) ||
- (len*sizeof(USHORT) == sizeof(VALUE) &&
- ds[sizeof(VALUE)/sizeof(USHORT)-1] <= 0x3fff)) {
+ if (len*sizeof(USHORT) <= sizeof(VALUE)) {
long num = 0;
while (len--) {
num = BIGUP(num) + ds[len];
}
- if (RBIGNUM(x)->sign) {
- if (POSFIXABLE(num)) return INT2FIX(num);
+ if (num >= 0) {
+ if (RBIGNUM(x)->sign) {
+ if (POSFIXABLE(num)) return INT2FIX(num);
+ }
+ else if (NEGFIXABLE(-num)) return INT2FIX(-num);
}
- else if (NEGFIXABLE(-num)) return INT2FIX(-num);
}
return x;
}