← CSC 116 Digital Logic and Electronics
Number Systems, Binary Conversion, and Computer Arithmetic
Notes
Introduction to Number Systems
Digital electronic computers process information using two discrete electrical voltage states, represented abstractly as binary zero and one. While human beings routinely calculate using the base-ten decimal system, computer hardware utilizes base-two binary representation due to the reliability of transistors operating in saturation or cutoff states. In computing, understanding conversions between decimal, binary, octal, and hexadecimal is fundamental because hexadecimal provides a compact shorthand for binary data such as memory addresses and machine code instructions.
Base Conversions and Binary Logic
A positional number system calculates the total value of a sequence by summing the product of each digit and its base raised to the power of its position index. To convert a decimal integer to binary, the successive division-by-two method is used, recording the remainders from least significant bit to most significant bit. Conversely, binary fractions are converted to decimal using negative powers of two, or from decimal to binary by successive multiplication by two. Hexadecimal represents four binary bits, termed a nibble, per character, allowing efficient human interpretation of large byte strings.
Signed Numbers and Twos Complement
Modern microprocessors represent negative integers using two's complement notation rather than sign-magnitude because it eliminates the problem of dual zeros and simplifies arithmetic logic unit circuitry. In two's complement arithmetic, subtraction is executed as addition with a negative operand. To determine the two's complement of a binary number, invert every bit to obtain the one's complement and then add one to the least significant bit.
Practical example
Consider an automated water dispensing kiosk deployed in Kibera, Nairobi, controlled by an embedded eight-bit microcontroller. The system records dispensed water volumes in integer liters. If the system starts with an allocated daily balance of 45 liters and a customer draws 19 liters, the microcontroller performs subtraction via two's complement addition.
First, convert positive 45 to eight-bit binary:
45 divided by 2 yields binary 00101101.
Next, convert positive 19 to eight-bit binary:
19 divided by 2 yields binary 00010011.
To represent negative 19, find its two's complement:
Invert all bits of 00010011 to get 11101100.
Add 1 to obtain 11101101.
Now, add 45 and negative 19:
00101101 (45)
+ 11101101 (-19)
= 100011010.
Discard the ninth overflow carry bit for an eight-bit register, leaving 00011010.
Converting 00011010 back to decimal:
16 plus 8 plus 2 equals 26 liters remaining. The transaction successfully reconciles without requiring specialized subtractor circuitry inside the kiosk controller.
Quiz
1. Why do digital computer systems rely heavily on two's complement for representing signed integers?
2. What is the two's complement representation of the decimal number -12 in an 8-bit system?
3. How many binary bits are directly represented by a single hexadecimal digit?
Sign in to submit and securely grade your quiz.