* [PATCH 3/7] simplify most significant byte modification statement
@ 2015-03-16 20:26 tyson.w.smith
0 siblings, 0 replies; only message in thread
From: tyson.w.smith @ 2015-03-16 20:26 UTC (permalink / raw)
To: davej; +Cc: trinity, tysmith, Tyson Smith
From: Tyson Smith <tyson.w.smith@gmail.com>
---
random.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/random.c b/random.c
index 7917f78..8b4f715 100644
--- a/random.c
+++ b/random.c
@@ -171,15 +171,9 @@ u64 rand64(void)
if (ONE_IN(25))
r = ~r;
- /* increase distribution in MSB */
- if (ONE_IN(10)) {
- unsigned int i;
- unsigned int rounds;
-
- rounds = rand() % 4;
- for (i = 0; i < rounds; i++)
- r |= (1UL << ((__WORDSIZE - 1) - (rand() % 8)));
- }
+ /* Set ~2 bits in MSB to increase distribution */
+ if (ONE_IN(10))
+ r |= (rand() & rand() & 0xffULL) << 56;
/* Sometimes flip sign */
if (ONE_IN(25))
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-16 20:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 20:26 [PATCH 3/7] simplify most significant byte modification statement tyson.w.smith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).