simplify most significant byte modification statement
PATCH 3/7 simplify most significant byte modification statement
From: Tyson Smith <[email protected]>
--- random.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
random.c +3 -9
@@ -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 ))
Signature · 1 line
1.9.1