File tree 1 file changed +6
-18
lines changed
1 file changed +6
-18
lines changed Original file line number Diff line number Diff line change 11
11
12
12
#include "flip.h"
13
13
14
- static int k = 31 ;
14
+ static int k = 30 ;
15
15
static int flip_word = 0 ;
16
- static int flip_pos = 31 ;
16
+ static int flip_pos = 0 ;
17
17
18
18
int flip (void ){
19
- if (flip_pos == k ) {
19
+ if (flip_pos == 0 ) {
20
20
flip_word = rand ();
21
- flip_pos = 0 ;
21
+ flip_pos = k ;
22
22
}
23
- return (flip_word >> flip_pos ++ ) & 1 ;
23
+ -- flip_pos ;
24
+ return (flip_word >> flip_pos ) & 1 ;
24
25
}
25
-
26
- // Old implementation scans from lower-to-higher order bits,
27
- // but rand() has poor quality on lower order bits.
28
- // int flip(void){
29
- // static int k = 31;
30
- // static int flip_word = 0;
31
- // static int flip_pos = 0;
32
- // if (flip_pos == 0) {
33
- // flip_word = rand();
34
- // flip_pos = k;
35
- // }
36
- // return (flip_word >> --flip_pos) & 1;
37
- // }
You can’t perform that action at this time.
0 commit comments