[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tyson Smith <tysmith@xxxxxxxxxxxx>

These operations provide value however if they happen too often it prevents
the use of unmodified values that are generated that are more significant.
---
 random.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/random.c b/random.c
index d671035..fd5f2c0 100644
--- a/random.c
+++ b/random.c
@@ -125,11 +125,11 @@ unsigned int rand32(void)
 	}
 
 	/* Sometimes deduct it from INT_MAX */
-	if (rand_bool())
+	if (ONE_IN(25))
 		r = INT_MAX - r;
 
 	/* Sometimes flip sign */
-	if (rand_bool())
+	if (ONE_IN(25))
 		r = ~r + 1;
 
 	/* we might get lucky if something is counting ints/longs etc. */
@@ -193,11 +193,11 @@ u64 rand64(void)
 	}
 
 	/* Sometimes invert the generated number. */
-	if (rand_bool())
+	if (ONE_IN(25))
 		r = ~r;
 
 	/* increase distribution in MSB */
-	if ((rand() % 10)) {
+	if (ONE_IN(10)) {
 		unsigned int i;
 		unsigned int rounds;
 
@@ -207,7 +207,7 @@ u64 rand64(void)
 	}
 
 	/* Sometimes flip sign */
-	if (rand_bool())
+	if (ONE_IN(25))
 		r = ~r + 1;
 
 	return r;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux