* numeric.c (fix_mul): get rid of shift overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2006-09-18 03:17:06 +00:00
parent 4048548f7f
commit 3851ac03b5
2 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,7 @@
Mon Sep 18 12:16:48 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (fix_mul): get rid of shift overflow.
Mon Sep 18 10:47:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_s_glob): remove unused variable.

View File

@ -1989,7 +1989,7 @@ fix_mul(VALUE x, VALUE y)
if (FIXABLE(d)) return LONG2FIX(d);
return rb_ll2inum(d);
#else
# define SQRT_LONG_MAX (1<<((SIZEOF_VALUE*CHAR_BIT-1)/2))
# define SQRT_LONG_MAX ((SIZEOF_VALUE)1<<((SIZEOF_VALUE*CHAR_BIT-1)/2))
/*tests if N*N would overflow*/
# define FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))
if (FIT_SQRT_LONG(a) && FIT_SQRT_LONG(b))