CampusLearn
← CSC 115 Computer Organization and Architecture

Data Representation and Computer Arithmetic

Notes

Introduction to Number Systems Computers operate fundamentally on electrical states represented as high or low voltages, which we abstract as binary digits or bits. In computer architecture, understanding how data is represented is essential for designing efficient arithmetic and logic circuits. While human users communicate using the base-10 decimal system, computing systems manipulate binary, octal, and hexadecimal values. Hexadecimal is particularly useful in computer engineering because it offers a human-readable shorthand for large binary strings, where each hexadecimal digit represents exactly four bits or a nibble. Negative Numbers and Two's Complement To perform arithmetic, processors need efficient methods to handle signed integers. Early architectures experimented with signed-magnitude and ones complement, but both suffered from architectural drawbacks, notably having two representations for zero and requiring complex end-around carry additions. Modern central processing units almost universally implement two's complement. In an n-bit two's complement system, the most significant bit serves as the sign bit, where zero indicates a positive value and one indicates a negative value. To derive the two's complement of a binary number, one inverts all bits and adds one to the least significant bit. This elegant design allows the arithmetic logic unit to perform subtraction using identical adder circuitry as addition. Practical example Consider an automated Safaricom M-Pesa merchant integration running on an Ubuntu server at an enterprise in Nairobi. A merchant account with a balance of 850 Kenyan Shillings incurs an overdraft fee or reversal deduction of 1,200 Kenyan Shillings. To determine the resulting balance at the hardware register level using 16-bit signed arithmetic, the processor converts both amounts to binary. The initial balance of 850 in 16-bit binary is 0000 0011 0101 0010. The deduction of 1,200 is represented as a negative value, negative 1,200. First, positive 1,200 in binary is 0000 0100 1011 0000. Inverting these bits yields 1111 1011 0100 1111. Adding one produces the two's complement representation: 1111 1011 0101 0000. The arithmetic logic unit adds 850 to negative 1,200: 0000 0011 0101 0010 plus 1111 1011 0101 0000 equals 1111 1110 1010 0010. Because the most significant bit is one, the result is negative. To read the human value, we invert the result to get 0000 0001 0101 1101 and add one, giving 0000 0001 0101 1110, which evaluates to decimal 350. The register successfully reflects a negative balance of 350 Kenyan Shillings without requiring specialized subtraction circuits.

Quiz

1. Why is two's complement preferred over signed-magnitude representation in processor design?

2. How many hexadecimal digits are needed to represent an 8-bit byte?

3. What is the two's complement representation of -5 in an 8-bit register?

Sign in to submit and securely grade your quiz.