summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-21 06:28:41 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-21 06:28:41 +0000
commitee2434851bb22974e0dbfd0cfaf3ebced6b38d68 (patch)
treec1062a7705ae74de45a4751cf33c80ec1a58b75c /bignum.c
parent9857cc6036a973e663f6ae057f7479ac1ce0f5d3 (diff)
* bignum.c (bignew_1): convertion from `int' to `char' discards
upper bits, (ie. (char)0xff00 -> 0) so it's better to test if nonzero and set 0 or 1 instead of simply casting ... as a flag usage. (but I believe this won't cause actual bug in current implementation) [ruby-dev:27055] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/bignum.c b/bignum.c
index a01c45c7b8..655e22f94e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -43,7 +43,7 @@ bignew_1(VALUE klass, long len, int sign)
{
NEWOBJ(big, struct RBignum);
OBJSETUP(big, klass, T_BIGNUM);
- big->sign = (char)sign;
+ big->sign = sign?1:0;
big->len = len;
big->digits = ALLOC_N(BDIGIT, len);
@@ -693,7 +693,7 @@ rb_big_to_s(int argc, VALUE *argv, VALUE x)
}
static unsigned long
-big2ulong(VALUE x, char *type, int check)
+big2ulong(VALUE x, const char *type, int check)
{
long len = RBIGNUM(x)->len;
BDIGIT_DBL num;
@@ -752,7 +752,7 @@ rb_big2long(VALUE x)
#if HAVE_LONG_LONG
static unsigned LONG_LONG
-big2ull(VALUE x, char *type)
+big2ull(VALUE x, const char *type)
{
long len = RBIGNUM(x)->len;
BDIGIT_DBL num;
@@ -1040,7 +1040,7 @@ bigsub(VALUE x, VALUE y)
}
}
- z = bignew(RBIGNUM(x)->len, (z == 0)?1:0);
+ z = bignew(RBIGNUM(x)->len, z==0);
zds = BDIGITS(z);
for (i = 0, num = 0; i < RBIGNUM(y)->len; i++) {