Permalink
Browse files

Fix random generation of bignums on 64-bit 10.6+ machines.

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3831 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 7b81c3b commit 9bb27513f44c62788163209d88a29e553273660f Patrick Thomson committed Mar 19, 2010
Showing with 4 additions and 0 deletions.
  1. +4 −0 random.c
View
@@ -473,7 +473,11 @@ limited_rand(struct MT *mt, unsigned long limit)
static VALUE
limited_big_rand(struct MT *mt, struct RBignum *limit)
{
+#if SIZEOF_BDIGITS < 8
const long len = (RBIGNUM_LEN(limit) * SIZEOF_BDIGITS + 3) / 4;
+#else
+ const long len = (RBIGNUM_LEN(limit) * SIZEOF_BDIGITS + 3) / 8;
+#endif
struct RBignum *val = (struct RBignum *)rb_big_clone((VALUE)limit);
RBIGNUM_SET_SIGN(val, 1);
#if SIZEOF_BDIGITS == 2

0 comments on commit 9bb2751

Please sign in to comment.