瀏覽代碼

fix quiz7

master
吴冕志 2 年之前
父節點
當前提交
0b3ebd841f
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. +3
    -2
      lab2/datalab-handout/bits.c

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

@ -252,13 +252,14 @@ int conditional(int x, int y, int z) {
int isLessOrEqual(int x, int y) {
int signx = x >> 31;
int signy = y >> 31;
int isnegpos = (signx ^ signy) & (~signx); // 0xFFFFF if signx = 1 sign y = 0
int isnegpos = (signx ^ signy) & (signx); // 0xFFFFF if signx = 1 sign y = 0
int isposneg = (signx ^ signy) & (signy);
int sign1 = ~(1 << 31); // 01111111...111
int absx = x & sign1;
int absy = y & sign1;
int diff = absy + (~absx) + 1;
int signdiff = diff >> 31;
int res = !isnegpos & !signdiff;
int res = !!isnegpos | (!isnegpos & !signdiff & !isposneg);
return res;
}
//4

Loading…
取消
儲存