Professional Documents
Culture Documents
2 Fundamentals Lecture
2 Fundamentals Lecture
Number Systems
Objectives
● Number Systems
● Number conversions
● Binary Arithmetic
● Negative Numbers
● Computer memory
● How is information stored
● Memory addressing
● Memory dimensions and size
● Types of Data
● Numeric, non-numeric and instructions
● Numeric ranges and floating point
Computing Systems
Number Systems
E.g. Octal (Base 8)
You might group things in ⭖s
What if you had ⭖ fingers ?
⭙◐◁ ⬡◤⭖ ◐ ◁
123 678
2 3
45
◻⬠
E.g. Octal (Base 8)
You might group things in ⭖s
What if you had ⭖ fingers ?
⭙◐◁ ⬡◤⭖ ◐ ?
123 678
2 0
Do we need ⭖ to mean 8?
45
We can use ⭖ to mean 0
◻⬠
0 introduced around 8th
Century (value and place
holder)
E.g. Binary (Base 2)
You might group things in 2s
Then in 2 x 2s (4s)
What if you had 2 symbols ? Then in 2 x 4s (8s)
Then in 2 x 8s (16s)
⭖⭙
⭙ ⭖ ⭖ ⭙ ⭙
01 1 0 0 1 1
Conversions between number
bases
● Subscripts are used to indicate the
base.
● e.g.
○ 0011 = 1011 ? ⟹ 001110 = 10112
○ 1234 = 4660 ? ⟹ 123416 = 466010
Computing Systems
Base subscript base
0 + 8 + 4 + 0 + 1 = 1310
Computing Systems
Conversions - Decimal to Binary
● Work right to left and keep dividing by 2 writing down
the remainder.
● E.g. 5010
● 50 / 2 = 25 r 0 (02) LSB
● 25 / 2 = 12 r 1 (12)
● 12 / 2 = 6 r 0 (02)
● 6 / 2 = 3 r 0 (02)
● 3 / 2 = 1 r 1 (12)
● 1 / 2 = 0 r 1 (12) MSB ∴ 5010 = 1100102
● It is easy to forget the last step (bad) or just write it in
(good)
Computing Systems
Hexadecimal (Hex.) – Base 16
● Why Bother ?
● Computers like Binary
● Humans like decimal
● We just learnt to convert between the two
● So why is Hexadecimal useful ?
● Binary is cumbersome for humans to read and write
and therefore error prone
● Hexadecimal is compact to write for humans
● It is very easy to convert hex. to and from binary.
Computing Systems
First 1016 Decimal, Hex and Binary values
3
2
3
0010
0011
answer for any binary to 4 4 0100
hex or hex to binary 5 5 0101
conversion by 6 6 0110
inspection. 7 7 0111
8 8 1000
● Just work from right to 9 9 1001
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Computing Systems
Hexadecimal and Binary
● This last point is true for any base which is itself a power of 2.
● This is because each column “fits” a number of binary columns
● For Hex, each column can have exactly 16 possible values.
● This requires 4 binary columns which also have exactly 16 possible values
● The Hex. symbols are: 0 1 2 3 4 5 6 7 8 9 A B C D E F
1 x 23 + 1 x 22 + 1 x 21 + 1 x 20 = 1510
8 + 4 + 2 + 1 = 1510
Computing Systems
Hexadecimal and Binary
1 x 23 + 1 x 22 + 0 x 21 + 0 x 20 = 1210
8 + 4 + 0 + 0 = 1210
Computing Systems
Hex ⇔Binary example
Decimal Hex Binary
3 6 5 16
0
1
0
1
0000
0001
⥮
2 2 0010
3 3 0011
4 4 0100
11 0110 0101
5 5 0101
2 6 6 0110
7 7 0111
8 8 1000
9 9 1001
⟸ 10
11
A
B
1010
1011
Computing Systems
Binary coded Decimal
Computing Systems
Converting Hex to Decimal
● Similar to doing binary to decimal, this is fairly easy once you
understand the maths behind positional number systems and
have the first 16 conversion table handy and can do powers of
16; 1, 16, 256, 4096, 65536, 1048576
● E.g. Express BAD16 in base 10
11 x 256 + 10 x 16 + 13 x 1 = 298910
Computing Systems
Computer representation of Hex
Computing Systems
Exercise
Computing Systems
More exercises
Computing Systems
Binary Arithmetic - addition
Computing Systems
How are negative numbers stored?
● Two’s complement
● E.g. 4 Bits
● Notice Negative all start
with 1
● Must fill all left hand bits
with 1 if –ve and using
more bits (sign extension)
● Write 2 to -3 using 8 bits
Computing Systems
Generating 2s Compliment
Computing Systems
And back
Computing Systems
Binary Arithmetic
Computing Systems
Is it 2s Compliment ? Sign extension
Computing Systems
Computer Memory
Computer Memory
• Main memory consists of a number of storage
locations containing 1s or 0s
• One Bit stores a single 0 or 1
• 1 Byte stores 8 bits. 4 bits is called a ?
• Each location stores a word i.e. the number of
bits that can be processed in a single operation.
Word length may be typically 16, 24, 32 or as
many as 64 bits.
• The Data bus has as many “wires” as the Word
length.
Computing Systems
Address Bus
Computing Systems
Memory Address and Data bus
H e l l o ,
Data
01001000 01100101 01101100 01101100 01101111 00101110
...
Address 00000101 0000 0110 0000 0111 0000 1000 0000 1001 0000 1010
Address Bus
Data Bus
Computing Systems
Memory Sizes
● Memory sizes
● 32 bit 232 (= 4 Gi) different memory
locations.
● 64 bit 264 (= 16 Ei )
● Questions
● What is the memory addressing capabilities
of your pc/laptop
● How much memory does it have
Computing Systems
Memory Hierarchy
● Consider : Capacity, Speed, Cost
Computing Systems
Binary and Decimal Prefixes
Computing Systems
Memory Modules
Computing Systems
Types of Data
What do these 1’s and 0’s represent?
● Numeric Data
● Integers (Signed and Unsigned)
● Decimal Numbers (Fixed and floating point)
● Non-Numeric Data
● Text, graphics, sound …
● Instructions
● Program code for the processor
Computing Systems
Storing Characters
● UTF-8 (backward compatible with ASCII)
● For coding and storing text
● Eg coding Keyboard characters
● Main encoding method for WWW
● What are ‘B’ and ‘b’ in decimal and hex
● Computer does not know the meaning of any of the
data in memory. Just a large set of ‘0’s and ‘1’s. It is
only when the context is known that the binary can be
interpreted.
● Look-up the following codes and write them in binary:
● ‘H’, ‘h’, ‘6’, ‘0’
Computing Systems
● end
Computing Systems