Computer Number Systems
Number Representation in Computers
Decimal System vs. Binary System
- Decimal System:
- Uses base 10.
- Columns represent powers of 10 (e.g., ones, tens, hundreds).
- Ten possible digits (0-9) for each placeholder.
- Binary System:
- Used by computers.
- Uses base 2.
- Based on transistors, which can be either off (0) or on (1).
- Columns represent powers of 2 (e.g., ones, twos, fours).
Place Values in Binary
- Decimal system columns represent powers of 10: 100,101,102, etc.
- Binary system columns represent powers of 2: 20,21,22, etc.
- Example:
- 20=1 (ones column)
- 21=2 (twos column)
- 22=4 (fours column)
- 23=8 (eights column)
- 24=16 (sixteens column)
- 25=32 (thirty-twos column)
- 26=64 (sixty-fours column)
- 27=128 (one-hundred-twenty-eights column)
Converting Binary to Decimal
- Multiply the digit in each binary column by its corresponding power of 2.
- Add the results to get the decimal equivalent.
- Example: Binary
000- (4×0)+(2×0)+(1×0)=0
- Example: Binary
001- (4×0)+(2×0)+(1×1)=1
- Example: Binary
010- (4×0)+(2×1)+(1×0)=2
- Example: Binary
011- (4×0)+(2×1)+(1×1)=3
- Example: Binary
100- (4×1)+(2×0)+(1×0)=4
- Example: Binary
101- (4×1)+(2×0)+(1×1)=5
- Example: Binary
110- (4×1)+(2×1)+(1×0)=6
- Example: Binary
111- (4×1)+(2×1)+(1×1)=7
Adding More Bits
- To count higher, add more bits (transistors).
- Each bit doubles the counting capacity.
- Example: Four bits
1000 in binary represents 8 in decimal ( (8×1)+(4×0)+(2×0)+(1×0)=8 ).
Bytes
- A byte is a unit of 8 bits.
- More practical than using only a few bits.
- A byte can represent numbers from 0 to 255.
Byte Representation Example
- Eight bits (one byte):
00000000 (decimal 0)
Maximum Value in a Byte
- With eight bits, the highest number you can count to is 255.
- All bits set to one:
11111111 - (128+64+32+16+8+4+2+1=255)
- Including zero, there are 256 total possibilities (0-255).
Significance of Powers of Two
- Numbers like 255 and 256 are common in computer systems because they relate to the units of measure (bytes) that systems use.