You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2012/04/07 13:18:55 UTC

[lucy-commits] svn commit: r1310739 - /lucy/trunk/core/Lucy/Test/TestUtils.c

Author: nwellnhof
Date: Sat Apr  7 11:18:55 2012
New Revision: 1310739

URL: http://svn.apache.org/viewvc?rev=1310739&view=rev
Log:
Fix TestUtils_random_u64

Properly mask bits from rand()

Modified:
    lucy/trunk/core/Lucy/Test/TestUtils.c

Modified: lucy/trunk/core/Lucy/Test/TestUtils.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Test/TestUtils.c?rev=1310739&r1=1310738&r2=1310739&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Test/TestUtils.c (original)
+++ lucy/trunk/core/Lucy/Test/TestUtils.c Sat Apr  7 11:18:55 2012
@@ -37,11 +37,11 @@
 
 uint64_t
 TestUtils_random_u64() {
-    uint64_t num = ((uint64_t)rand()   << 60)
-                   | ((uint64_t)rand() << 45)
-                   | ((uint64_t)rand() << 30)
-                   | ((uint64_t)rand() << 15)
-                   | ((uint64_t)rand() << 0);
+    uint64_t num = ((uint64_t)(rand()   & 0x7FFF) << 60)
+                   | ((uint64_t)(rand() & 0x7FFF) << 45)
+                   | ((uint64_t)(rand() & 0x7FFF) << 30)
+                   | ((uint64_t)(rand() & 0x7FFF) << 15)
+                   | ((uint64_t)(rand() & 0x7FFF) << 0);
     return num;
 }