Skip to content

Commit f7ba81d

Browse files
committed
Revert "Fix #10; skipping final bit in flip.c"
This reverts commit 0b143a0.
1 parent 195b4cd commit f7ba81d

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/c/flip.c

+6-18
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,15 @@
1111

1212
#include "flip.h"
1313

14-
static int k = 31;
14+
static int k = 30;
1515
static int flip_word = 0;
16-
static int flip_pos = 31;
16+
static int flip_pos = 0;
1717

1818
int flip(void){
19-
if (flip_pos == k) {
19+
if (flip_pos == 0) {
2020
flip_word = rand();
21-
flip_pos = 0;
21+
flip_pos = k;
2222
}
23-
return (flip_word >> flip_pos++) & 1;
23+
--flip_pos;
24+
return (flip_word >> flip_pos) & 1;
2425
}
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-
// }

0 commit comments

Comments
 (0)