some change in lab1

This commit is contained in:
2025-09-26 01:18:42 +09:00
parent 901757b211
commit 791672d18d

View File

@@ -1,7 +1,7 @@
/*
* CSE4009 Assignment 1 - Data Lab
*
* <Please put your name and userid here>
* name: Hajin Ju, id: 2024062806
*
* bits.c - Source file with your solutions to the Lab.
* This is the file you will hand in to your instructor.
@@ -132,7 +132,6 @@ NOTES:
* the correct answers.
*/
#endif
/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -178,7 +177,7 @@ NOTES:
* Rating: 1
*/
int bitAnd(int x, int y) {
return 2;
return ~(~x | ~y);
}
/*
* bitXor - x^y using only ~ and &
@@ -188,7 +187,7 @@ int bitAnd(int x, int y) {
* Rating: 1
*/
int bitXor(int x, int y) {
return 2;
return x & ~y | ~x & y;
}
/*
* isTmin - returns 1 if x is the minimum, two's complement number,
@@ -198,7 +197,7 @@ int bitXor(int x, int y) {
* Rating: 1
*/
int isTmin(int x) {
return 2;
return !!x & !(x ^ (~x + 1));
}
//2
/*
@@ -209,7 +208,7 @@ int isTmin(int x) {
* Rating: 2
*/
int isEqual(int x, int y) {
return 2;
}
/*
* negate - return -x
@@ -219,7 +218,7 @@ int isEqual(int x, int y) {
* Rating: 2
*/
int negate(int x) {
return 2;
return ~x + 1;
}
/*
* getByte - Extract byte n from word x