Explorar el Código

Finish isLessOrEqual

main
邓博昊 hace 8 meses
padre
commit
6e57a492d8
Se han modificado 2 ficheros con 9 adiciones y 2 borrados
  1. +7
    -2
      LAB1/bits.c
  2. +2
    -0
      README.md

+ 7
- 2
LAB1/bits.c Ver fichero

@ -254,7 +254,9 @@ int isAsciiDigit(int x) {
* Rating: 3
*/
int conditional(int x, int y, int z) {
return 2;
x = !!(x);
x = ~x+1;
return (x&y)|(~x&z);
}
/*
* isLessOrEqual - if x <= y then return 1, else return 0
@ -264,7 +266,10 @@ int conditional(int x, int y, int z) {
* Rating: 3
*/
int isLessOrEqual(int x, int y) {
return 2;
int tmp = ~y+1;
tmp = tmp+x-1;
tmp = tmp >> 31;//y大0y小等于1
return !!tmp;
}
//4
/*

+ 2
- 0
README.md Ver fichero

@ -17,3 +17,5 @@ A CSAPP LAB
3. Finish negate
4. Finish isAsciiDigit
5. Finish isLessOrEqual

Cargando…
Cancelar
Guardar