Browse Source

Finish LogicalNeg and Update Makefile

main
邓博昊 11 months ago
parent
commit
3edd739a66
3 changed files with 12 additions and 1 deletions
  1. +7
    -0
      LAB1/Makefile
  2. +1
    -1
      LAB1/bits.c
  3. +4
    -0
      README.md

+ 7
- 0
LAB1/Makefile View File

@ -23,4 +23,11 @@ btestexplicit:
clean: clean:
rm -f *.o btest fshow ishow *~ rm -f *.o btest fshow ishow *~
oneshoot:
make clean; \
./dlc bits.c; \
make btest; \
./btest bits.c; \
make clean \

+ 1
- 1
LAB1/bits.c View File

@ -281,7 +281,7 @@ int isLessOrEqual(int x, int y) {
* Rating: 4 * Rating: 4
*/ */
int logicalNeg(int x) { int logicalNeg(int x) {
return 2;
return ((x|(~x+1))>>31)+1;
} }
/* howManyBits - return the minimum number of bits required to represent x in /* howManyBits - return the minimum number of bits required to represent x in
* two's complement * two's complement

+ 4
- 0
README.md View File

@ -19,3 +19,7 @@ A CSAPP LAB
4. Finish isAsciiDigit 4. Finish isAsciiDigit
5. Finish isLessOrEqual 5. Finish isLessOrEqual
6. Finish logicalNeg
7. Update Makefile

Loading…
Cancel
Save