瀏覽代碼

fix quiz8

master
吴冕志 1 年之前
父節點
當前提交
fe36d7f134
共有 1 個檔案被更改,包括 2 行新增3 行删除
  1. +2
    -3
      lab2/datalab-handout/bits.c

+ 2
- 3
lab2/datalab-handout/bits.c 查看文件

@ -259,7 +259,7 @@ int isLessOrEqual(int x, int y) {
int absy = y & sign1;
int diff = absy + (~absx) + 1;
int signdiff = diff >> 31;
int res = !(!isnegpos) | (!isnegpos & !signdiff & !isposneg);
int res = (!(!isnegpos)) | (!isnegpos & !signdiff & !isposneg);
return res;
}
//4
@ -275,10 +275,9 @@ int logicalNeg(int x) {
int sign = (x ^ (~x + 1)) >> 31;
int one = 1;
int singlesign = sign & one;
int intmin = 1 << 31;
int isnotmin = (~x) >> 31; // if x is 00000, get 1111 and if x is 1000 get 00000
int notmin = isnotmin & one;
int res = singlesign ^ one & notmin;
int res = (singlesign ^ one) & notmin;
return res;
}
/* howManyBits - return the minimum number of bits required to represent x in

Loading…
取消
儲存