You are on page 1of 22

The Number System

Data Representation?

Representation = Measurement
§ Most things in the “Real World” actually exist as a single, continuously varying
quantity
§ Mass, Volume, Speed, Pressure, Temperature
§ Easy to measure by “representing” it using a different thing that varies in the same
way
§ Eg. Pressure as the height of column of mercury or as voltage produced by a pressure
transducer
§ These are ANALOG measurements
Digital Representation

§ DIGITAL measurements
§ In units - a set of symbolic values – digits
§ Values larger than any symbol in the set use sequence of digits
§ Units, Tens, Hundreds
§ Measured in discrete or whole units
Number Systems

§ Human beings use decimal (base 10)


§ probably because we have 10 fingers
§ Computers use binary (base 2)
§ as they are made from binary digital components (known as transistor) operating in two states
– on and off.
§ In computing, we also use hexadecimal (base 16) or octal (base 8)
Decimal (base 10)

§ Ten distinct symbols:


§ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
§ For an n-digit number, the value that each digit represents depends on its weight or
position
§ Uses positional notation (powers of 10)

73510 = 7x102 + 3x101 + 5x100


Binary (base 2)

§ Two distinct symbols:


§ 0, 1
§ For an n-digit number, the value that each digit represents depends on its position
§ Uses positional notation (powers of 2)

101102 = 1x24 + 0x23 + 1x22 + 1x21 + 0x20


Octal (base 8)

§ Eight distinct symbols:


§ 0, 1, 2, 3, 4, 5, 6, 7, 8
§ For an n-digit number, the value that each digit represents depends on its position
§ Uses positional notation (powers of 8)

75128 = 7x83 + 5x82 + 1x81 + 2x80


Hexadecimal (base 16)

§ Sixteen distinct symbols:


§ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
§ Uses positional notation (powers of 16)

A3E16 = Ax162 + 3x161 + Ex160


Hexadecimal (base 16)

§ Computers uses binary system in their internal operations, as they are built from
binary digital electronic components.
§ However, writing or reading a long sequence of binary bits is cumbersome and
error-prone.
§ Hexadecimal system is used as a compact form or shorthand for binary bits.
Hexadecimal (base 16)

§ Each hex digit is equivalent to 4 binary bits, i.e.


Conversions between Number Systems

INTRODUCTION TO COMPUTERS
Base-n to Decimal

Binary 1 0 1 1 0
(base-2) 1x24 + 0x23 + 1x22 + 1x21 + 0x20
16 + 0 + 4 + 2 + 0 = 2210
Octal 7 5 1 2
(base-8) 7x83 + 5x82 + 1x81 + 2x80
3584 + 320 + 8 + 2 = 391410
Hexa A 3 E
(base-16) Ax162 + 3x161 + Ex160
2560 + 48 + 14 = 262210
Base-n to Binary

Decimal use repeated division/remainder

Value Quotient Remainder

22 / 2 11 0

11 / 2 5 1

5/2 2 1

2/2 2210 =1 101102 0

1/2 0 1
Base-n to Binary

Octal represent each digit with its


corresponding 3-digit binary

7 5 1 2
111 101 001 011

75128 = 1111010010112
Base-n to Binary

Hexa represent each digit with its


corresponding 4-digit binary

A 3 E
1010 0011 1110

A3E16 = 1010001111102
Base-n to Octal

Decimal use repeated division/remainder

Value Quotient Remainder

3914 / 8 489 2

489 / 8 61 1

61 / 8 7 5

7/8 3914100 = 75128 7


Base-n to Octal

Binary group bits by 3 and convert each group

101 000 111 110


5 0 7 6

1010001111102 = 50768
Base-n to Hexadecimal

Decimal use repeated division/remainder

Value Quotient Remainder

2622 / 16 163 E

163 / 16 10 3

10 / 16 0 A

262210 = A3E16
Base-n to Hexadecimal

Binary group bits by 3 and convert to decimal

1111 0100 1011


F 4 B

1111010010112 = F4B16
Octal to Hexadecimal and vice versa

Octal to Hexadecimal
1. Convert octal to binary
2. Convert binary to hexadecimal

Hexadecimal to Octal
1. Convert hexadecimal to binary
2. Convert binary to octal
Arithmetic Operations (Base 2)

INTRODUCTION TO COMPUTERS
Example: Base 2 (Binary)

First Second
Operator Result
Number Number
110 1011 + 11 1001 1010 0100
1 1001 - 1011 1110
11 1001 x 110 1 0101 0110
110 1110 / 1010 1011
*observe demo for detailed solution

You might also like