Data Lab
The Data Lab involved solving a series of programming puzzles designed to enhance my proficiency with bitwise operations and arithmetic in two's complement representation. Each puzzle came with its own set of challenges and required adhering to strict coding rules, pushing me to think creatively and efficiently.
Below I will describe the puzzles and the technical skills and tools I've utilized.
Bit Manipulation Functions:
- implication(x, y): Compute the logical implication 𝑥 → 𝑦
- anyOddBit(x): Check if any odd-indexed bit in x is set to 1.
- byteSwap(x, n, m): Swap the n-th and m-th bytes of x.
- logicalShift(x, n): Perform a logical right shift on x by n positions.
- conditional(x, y, z): Implement the ternary conditional operator (x ? y : z).
Two's Complement Arithmetic Functions:
- dividePower2(x, n): Compute 𝑥 / 2𝑛 rounding towards zero.
- addOK(x, y): Check if adding x and y results in overflow.
- remainderPower2(x, n): Compute 𝑥 % 2𝑛 ensuring negative arguments yield negative remainders.
- isNonZero(x): Determine if x is nonzero without using the ! operator.
- trueFiveEighths(x): Multiply x by 5 / 8, avoiding overflow.
- isPalindrome(x): Check if the bit pattern of x is a palindrome.
Bit-Level Manipulations
- Implemented Functions: Created functions to manipulate and test sets of bits using only a limited set of operators (! ~ & ^ | + << >>). This required a deep understanding of how these operators interact at the binary level.
Two's Complement Arithmetic
- Arithmetic Functions: Solved puzzles that involved arithmetic operations using two's complement representation, ensuring efficient and correct implementations.
Completing the Data Lab has equipped me with a robust understanding of bit-level operations and two's complement arithmetic. The skills I honed during this project are not only foundational for low-level programming but also critical for developing efficient and reliable software.
- C
- Bitwise Operations
- Two's Complement Arithmetic
- Low-Level Programming
- Bit-Level Programming
- Integer Arithmetic
- Logical Shifts
- Overflow Detection