PHYSICS140 LECTURE 3
Numbers in Binary
Previously covered concepts: adding binary numbers, multiplying them, and representing negative numbers using two's complement.
Two's Complement Representation:
Example: +13 is represented as
00001101.To convert it to -13, invert the bits and add one:
Step 1: Invert
00001101→11110010.Step 2: Add 1 →
11110010 + 1 = 11110011, which is -13 in binary (5-bits).
Example Exercise (2's Complement)
- Find -13 in 5-bit two's complement:
+13 in binary →
01101(with leading zeros)Negative Conversion: Inverting gives
10010(from01101) and adding one gives10011, confirming representation.Most significant bit denotes positives/negatives.
Multiplication of Signed Numbers
Process for multiplying signed numbers:
Turn negatives to positives with two's complement before multiplication.
Example for Multiplication:
Multiply -3 by 4.
Step 1: Represent -3 in binary:
+3 is
00011.Convert to -3: Invert →
11100, Add 1 →11101.
Step 2: Represent 4 in binary →
00100.Step 3: Perform multiplication:
11101(which represents -3)×
00100(which represents 4)Result in binary is
1111100, which translates to -12 in decimal.
Determine sign of result based on multiplication rules (negative × positive = negative).
Introduction to Hexadecimal
Hexadecimal as a compact way to represent binary values (base 16).
Each hexadecimal digit corresponds to four binary digits.
Example:
C3in hex equals11000111in binary.Counting in hexadecimal:
Counts range from 0 to F, where A=10, B=11, C=12, D=13, E=14, F=15.
Example Conversion from Hex to Decimal:
Hex
C3:Calculate using place value based on powers of 16:
C × 16^1 + 3 × 16^0
(12×16 + 3×1 = 192 + 3 = 195).
Hex to Binary: Each hex digit translates to four binary digits.
Example:
C=1100,3=0011→ Overall:11000011.
Storing Information in Binary
Distinction between codes and arithmetic.
Binary Coded Decimal (BCD):
Represents decimal digits using 4-bit binary codes; each digit is separate (e.g., 4563 →
0100 0101 0110 0011).Highlighted the non-arithmetic nature of stored information versus representational numbers.
Practical application in systems like telephones to register key presses, not compute values.
Next Lecture Preview
Focus on further codes, particularly how to store letters and plain text in computing systems.
Encouraged to practice binary and hexadecimal exercises on Canvas.