зеркало из https://github.com/github/ruby.git
Refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
164e04ba4a
Коммит
1acc9062bc
16
bignum.c
16
bignum.c
|
@ -1236,9 +1236,8 @@ rb_big2ulong(VALUE x)
|
|||
return -(long)num;
|
||||
if (num == 1+(unsigned long)(-(LONG_MIN+1)))
|
||||
return LONG_MIN;
|
||||
rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
|
||||
}
|
||||
return num;
|
||||
rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
|
||||
}
|
||||
|
||||
SIGNED_VALUE
|
||||
|
@ -1247,8 +1246,7 @@ rb_big2long(VALUE x)
|
|||
VALUE num = big2ulong(x, "long", TRUE);
|
||||
|
||||
if (RBIGNUM_POSITIVE_P(x)) {
|
||||
if (LONG_MAX < num)
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
|
||||
if (num <= LONG_MAX)
|
||||
return num;
|
||||
}
|
||||
else {
|
||||
|
@ -1256,8 +1254,8 @@ rb_big2long(VALUE x)
|
|||
return -(long)num;
|
||||
if (num == 1+(unsigned long)(-(LONG_MIN+1)))
|
||||
return LONG_MIN;
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
|
||||
}
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
|
||||
}
|
||||
|
||||
#if HAVE_LONG_LONG
|
||||
|
@ -1293,9 +1291,8 @@ rb_big2ull(VALUE x)
|
|||
return -(LONG_LONG)num;
|
||||
if (num == 1+(unsigned LONG_LONG)(-(LLONG_MIN+1)))
|
||||
return LLONG_MIN;
|
||||
rb_raise(rb_eRangeError, "bignum out of range of unsigned long long");
|
||||
}
|
||||
return num;
|
||||
rb_raise(rb_eRangeError, "bignum out of range of unsigned long long");
|
||||
}
|
||||
|
||||
LONG_LONG
|
||||
|
@ -1304,8 +1301,7 @@ rb_big2ll(VALUE x)
|
|||
unsigned LONG_LONG num = big2ull(x, "long long");
|
||||
|
||||
if (RBIGNUM_POSITIVE_P(x)) {
|
||||
if (LLONG_MAX < num)
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
|
||||
if (num <= LLONG_MAX)
|
||||
return num;
|
||||
}
|
||||
else {
|
||||
|
@ -1313,8 +1309,8 @@ rb_big2ll(VALUE x)
|
|||
return -(LONG_LONG)num;
|
||||
if (num == 1+(unsigned LONG_LONG)(-(LLONG_MIN+1)))
|
||||
return LLONG_MIN;
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
|
||||
}
|
||||
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
|
||||
}
|
||||
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
|
Загрузка…
Ссылка в новой задаче