some change in lab1
This commit is contained in:
@@ -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
|
||||
@@ -230,7 +229,7 @@ int negate(int x) {
|
||||
* Rating: 2
|
||||
*/
|
||||
int getByte(int x, int n) {
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
//3
|
||||
/*
|
||||
@@ -241,7 +240,7 @@ int getByte(int x, int n) {
|
||||
* Rating: 3
|
||||
*/
|
||||
int isLess(int x, int y) {
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
/*
|
||||
* conditional - same as x ? y : z
|
||||
@@ -251,7 +250,7 @@ int isLess(int x, int y) {
|
||||
* Rating: 3
|
||||
*/
|
||||
int conditional(int x, int y, int z) {
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
//4
|
||||
/*
|
||||
@@ -266,7 +265,7 @@ int conditional(int x, int y, int z) {
|
||||
* Rating: 4
|
||||
*/
|
||||
unsigned floatScale2(unsigned uf) {
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
/*
|
||||
* floatFloat2Int - Return bit-level equivalent of expression (int) f
|
||||
@@ -281,5 +280,5 @@ unsigned floatScale2(unsigned uf) {
|
||||
* Rating: 4
|
||||
*/
|
||||
int floatFloat2Int(unsigned uf) {
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user