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 * 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. * bits.c - Source file with your solutions to the Lab.
* This is the file you will hand in to your instructor. * This is the file you will hand in to your instructor.
@@ -132,7 +132,6 @@ NOTES:
* the correct answers. * the correct answers.
*/ */
#endif #endif
/* Copyright (C) 1991-2020 Free Software Foundation, Inc. /* Copyright (C) 1991-2020 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@@ -178,7 +177,7 @@ NOTES:
* Rating: 1 * Rating: 1
*/ */
int bitAnd(int x, int y) { int bitAnd(int x, int y) {
return 2; return ~(~x | ~y);
} }
/* /*
* bitXor - x^y using only ~ and & * bitXor - x^y using only ~ and &
@@ -188,7 +187,7 @@ int bitAnd(int x, int y) {
* Rating: 1 * Rating: 1
*/ */
int bitXor(int x, int y) { 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, * isTmin - returns 1 if x is the minimum, two's complement number,
@@ -198,7 +197,7 @@ int bitXor(int x, int y) {
* Rating: 1 * Rating: 1
*/ */
int isTmin(int x) { int isTmin(int x) {
return 2; return !!x & !(x ^ (~x + 1));
} }
//2 //2
/* /*
@@ -209,7 +208,7 @@ int isTmin(int x) {
* Rating: 2 * Rating: 2
*/ */
int isEqual(int x, int y) { int isEqual(int x, int y) {
return 2;
} }
/* /*
* negate - return -x * negate - return -x
@@ -219,7 +218,7 @@ int isEqual(int x, int y) {
* Rating: 2 * Rating: 2
*/ */
int negate(int x) { int negate(int x) {
return 2; return ~x + 1;
} }
/* /*
* getByte - Extract byte n from word x * getByte - Extract byte n from word x
@@ -230,7 +229,7 @@ int negate(int x) {
* Rating: 2 * Rating: 2
*/ */
int getByte(int x, int n) { int getByte(int x, int n) {
return 2; return 2;
} }
//3 //3
/* /*
@@ -241,7 +240,7 @@ int getByte(int x, int n) {
* Rating: 3 * Rating: 3
*/ */
int isLess(int x, int y) { int isLess(int x, int y) {
return 2; return 2;
} }
/* /*
* conditional - same as x ? y : z * conditional - same as x ? y : z
@@ -251,7 +250,7 @@ int isLess(int x, int y) {
* Rating: 3 * Rating: 3
*/ */
int conditional(int x, int y, int z) { int conditional(int x, int y, int z) {
return 2; return 2;
} }
//4 //4
/* /*
@@ -266,7 +265,7 @@ int conditional(int x, int y, int z) {
* Rating: 4 * Rating: 4
*/ */
unsigned floatScale2(unsigned uf) { unsigned floatScale2(unsigned uf) {
return 2; return 2;
} }
/* /*
* floatFloat2Int - Return bit-level equivalent of expression (int) f * floatFloat2Int - Return bit-level equivalent of expression (int) f
@@ -281,5 +280,5 @@ unsigned floatScale2(unsigned uf) {
* Rating: 4 * Rating: 4
*/ */
int floatFloat2Int(unsigned uf) { int floatFloat2Int(unsigned uf) {
return 2; return 2;
} }