Browse Source

finish quiz4

master
吴冕志 3 years ago
parent
commit
0a1d0cd33d
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      lab2/datalab-handout/bits.c

+ 9
- 1
lab2/datalab-handout/bits.c View File

@ -188,7 +188,15 @@ int isTmax(int x) {
* Rating: 2 * Rating: 2
*/ */
int allOddBits(int x) { int allOddBits(int x) {
return 2;
int base = 42;
int neg = 1 << 7;
int unit8 = base + neg;
int unit16 = (unit8 << 8) + unit8;
int unit32 = (unit16 << 16) + unit16;
int shouldunit32 = x & unit32;
int allzero = shouldunit32^unit32;
int res = !allzero;
return res;
} }
/* /*
* negate - return -x * negate - return -x

Loading…
Cancel
Save