Sie sind auf Seite 1von 11

# 1.

## 1.1.1 NUMBER REPRESENTATION

 Understanding Of The Basis Of Different Number Systems And Use The Binary, Denary And

## Number System Base No. of Digits Digits

Binary 2 2 0, 1

R
Octal 8 8 0,1,2,3,4,5,6,7

Decimal 10 10 0,1,2,3,4,5,6,7,8,9

KU

##  Convert a number from one number system to another

A
In base 16 we have sixteen symbols to represent each digit.
0 0 0000
1 1 0001
TH
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
ED

9 9 1001
10 A 1010
11 B 1011
12 C 1100
HM

13 D 1101
14 E 1110
15 F 1111
It is easy to convert from binary to hex and hex is easier to read than a long string of 1s and 0s.

## Converting From Binary To Hexadecimal

Step 1
Divide the binary number into groups of four digits starting
0111 0101
at the LSB.
A

Step 2
Write down the hexadecimal equivalent for each group 7 5
of digits.

## Converting From Hexadecimal To Denary

To perform this operation we use the same method as for converting a binary number to decimal.
However the column headings are in powers of sixteen not powers of two.

ahmed_thakur@hotmail.com, 0300-8268885 Page 1
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## Binary Coded Decimal

This variation of binary allows denary digits to be encoded separately.
E.g. 271910 is represented by:
2 7 1 9
0010 0111 0001 1001
271910 = 0010 0111 0001 1001BCD

R
 Easy to convert binary to BCD.
 No error due to round off.

KU
 Occupies more memory.
 Can be harder to perform arithmetic operations.

Whenever the sum of any two BCD digits is greater than 1001 2 then 01102 has to be added to the

A
result to skip over the unused codes.

##  Express a positive or negative integer in two’s complement form

Positive integers are generally stored as simple binary numbers. 1 is 1, 10 is 2, 11 is 3, etc.. Negative
TH
integers are stored as the two's complement of their absolute value, i.e. of the corresponding positive
integer. The two's complement of a positive number is, when using this notation, a negative number.

In order to flip the sign of a number, you always calculate the two's complement of that number: flip
all bits, then add 1. This is independent of whether the original number is positive or negative.

Example: 3 in 8-bit signed binary notation is 00000011. To flip the sign, you first flip all bits (11111100),
then add 1 (11111101). So, -3 is 11111101. To flip the sign again, you first flip all bits (00000010), then
ED

add 1 (00000011), and you can see that this is the same 3.

Nearly all computers work purely in binary. That means that they only use ones and zeros, and there's
no - or + symbol that the computer can use. The computer must represent negative numbers in a
different way.
HM

We can represent a negative number in binary by making the most significant bit (MSB) a sign bit,
which will tell us whether the number is positive or negative. The column headings for an 8 bit number
will look like this:

-128 64 32 16 8 4 2 1

MSB LSB

1 0 1 1 1 1 0 1
A

Here, the most significant bit is negative, and the other bits are positive. You start with -128, and add
the other bits as normal. The example above is -67 in denary because: (-128 + 32 + 16 + 8 + 4 + 1 = -
67)

-1 in binary is 11111111.
Note that you only use the most significant bit as a sign bit if the number is specified as signed. If the
number is unsigned, then the msb is positive regardless of whether it is a one or not.

ahmed_thakur@hotmail.com, 0300-8268885 Page 2
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## Signed binary numbers

If the MSB is 0 then the number is positive, if 1 then the number is negative.

## 0000 0101 (positive)

1111 1011 (negative)

R
Method: Converting a Negative Denary Number into Binary Twos Complement

KU
Let's say you want to convert -35 into Binary Twos Complement. First, find the binary
equivalent of 35 (the positive version)

32 16 8 4 2 1

A
1 0 0 0 1 1

Now add an extra bit before the MSB, make it a zero, which gives you:
TH
64 32 16 8 4 2 1
0 1 0 0 0 1 1

64 32 16 8 4 2 1
ED

1 0 1 1 1 0 0

HM

64 32 16 8 4 2 1
1 0 1 1 1 0 0
+ 1
1 0 1 1 1 0 1

## If we perform a quick binary  denary conversion, we have: -64 + 16 + 8 + 4 + 1 = -64 + 29

= -35
A

ahmed_thakur@hotmail.com, 0300-8268885 Page 3
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## Converting Negative Numbers

To find out the value of a twos complement number we must first make note of its sign bit (the most
significant, left most bit), if the bit is a zero we work out the number as usual, if it's a one we are
dealing with a negative number and need to find out its value.

## Method 1: converting twos complement to denary

R
To find the value of the negative number we must find and keep the right most 1 and all
bits to its right, and then flip everything to its left. Here is an example:

KU
1111 1011 note the number is negative
1111 1011 find the right most one
1111 1011
0000 0101 flip all the bits to its left

A
We can now work out the value of this new number which is:

128 64 32 16 8 4 2 1
TH
0 0 0 0 0 1 0 1
4 + 1 = −5 (remember the sign you worked out
earlier!)
ED

## Method 2: converting twos complement to denary

To find the value of the negative number we must take the MSB and apply a negative value
HM

## 1111 1011 note the number is negative

-128 64 32 16 8 4 2 1
1 1 1 1 1 0 1 1
-128 +64 +32 +16 +8 +2 +1 = -5
A

ahmed_thakur@hotmail.com, 0300-8268885 Page 4
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## 1.1.1 NUMBER REPRESENTATION

So we know how to work out the value of a negative number that has been given to us. How do we
go about working out the negative version of a positive number? Like this, that's how...

## Take the binary version of the positive number

R
0000 0101 (5)

KU
0000 0101 find the right most one

0000 0101
1111 1011 flip all the bits to its left

A
So now we can see the difference between a positive and a negative number

## 0000 0101 (5)

1111 1011 (−5)
TH
Method 2: converting twos complement to binary

Take the binary version of the positive number starting with -128, we know the MSB
is worth -128. We need to work back from this:
ED

-128 64 32 16 8 4 2 1
1 1 1 1 1 0 1 0
-128 +64 +32 +16 +8 +1 = -5
0000 0101 (5)
HM

## 1111 1011 (−5)

A

ahmed_thakur@hotmail.com, 0300-8268885 Page 5
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## 1. Convert the following two's complement numbers into denary

a. 0001 1011
b. 1111 1111
c. 0111 1101
d. 1001 1001

R

KU
Convert the following numbers into negative numbers written in binary
g. 000 0001
h. 0110 0000
i. 0111 1111

j. 12 (denary)

A
k. 67 (denary)
l. 34
TH
ED
HM
A

ahmed_thakur@hotmail.com, 0300-8268885 Page 6
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## 1.1.1 NUMBER REPRESENTATION

Binary Subtraction

## Example: binary subtraction

When it comes to subtracting one number from another in binary things can get very messy.

## X (82 denary) 0101 0010

R
Y (78 denary) 0100 1110 −

KU
An easier way to subtract Y from X is to add the negative value of Y to the value of X

X−Y = X+(−Y)

## To do this we first need to find the negative value of Y (78 denary)

A
0100 1110 find the right most one TH
0100 1110
1011 0010 flip all the bits to its left

ED

## 1011 0010 + Y(−78 denary)

0000 0100
(¹)¹¹¹ ¹ the one carried over the bit 9 is ignored

## Which comes out as:

HM

128 64 32 16 8 4 2 1
0 0 0 0 0 1 0 0
4 = 4 = 82-78
A

ahmed_thakur@hotmail.com, 0300-8268885 Page 7
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## Exercise: Binary subtraction

Find the answers to the following sums in binary, show your working

- 0000 0111 (7)

R
0001 1111 (31)

KU
- 0001 0011 (19)

## 0111 0111 (119)

- 0101 1011 (91)

A
23 (hex)
- 1F (hex)
TH
0001 0010 (10)
- 1110 0001 (-31)

Further Notes
ED

 Understanding of, and be able to represent, character data in its internal binary form depending
on the character set used (Candidates will not be expected to memorise any particular
character codes but must be familiar with ASCII and Unicode.)

## ASCII Standard Character Set

HM

Char Ctrl Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex

<space
NUL ^@ 0 00 > 32 20 @ 64 40 ` 96 60

SOH ^A 1 01 ! 33 21 A 65 41 a 97 61

STX ^B 2 02 " 34 22 B 66 42 b 98 62
A

ETX ^C 3 03 # 35 23 C 67 43 c 99 63

EOT ^D 4 04 \$ 36 24 D 68 44 d 100 64

ENQ ^E 5 05 % 37 25 E 69 45 e 101 65

## BEL ^G 7 07 ' 39 27 G 71 47 g 103 67

ahmed_thakur@hotmail.com, 0300-8268885 Page 8
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## 1.1.1 NUMBER REPRESENTATION

BS ^H 8 08 ( 40 28 H 72 48 h 104 68

HT ^I 9 09 ) 41 29 I 73 49 i 105 69

LF ^J 10 0A * 42 2A J 74 4A j 106 6A

VT ^K 11 0B + 43 2B K 75 4B k 107 6B

R
FF ^L 12 0C , 44 2C L 76 4C l 108 6C

KU
CR ^M 13 0D - 45 2D M 77 4D m 109 6D

SO ^N 14 0E . 46 2E N 78 4E n 110 6E

SI ^O 15 0F / 47 2F O 79 4F o 111 6F

DLE ^P 16 10 0 48 30 P 80 50 p 112 70

A
DC1 ^Q 17 11 1 49 31 Q 81 51 q 113 71

DC2 ^R 18 12 2 50 32 R 82 52 r 114 72

DC3 ^S 19 13 3
TH
51 33 S 83 53 s 115 73

DC4 ^T 20 14 4 52 34 T 84 54 t 116 74

NAK ^U 21 15 5 53 35 U 85 55 u 117 75

SYN ^V 22 16 6 54 36 V 86 56 v 118 76

ETB ^W 23 17 7 55 37 W 87 57 w 119 77
ED

CAN ^X 24 18 8 56 38 X 88 58 x 120 78

EM ^Y 25 19 9 57 39 Y 89 59 y 121 79

SUB ^Z 26 1A : 58 3A Z 90 5A z 122 7A
HM

ESC ^[ 27 1B ; 59 3B [ 91 5B { 123 7B

FS ^\ 28 1C < 60 3C \ 92 5C | 124 7C

GS ^] 29 1D = 61 3D ] 93 5D } 125 7D

RS ^^ 30 1E > 62 3E ^ 94 5E ~ 126 7E

<del
A

e
US ^_ 31 1F ? 63 3F _ 95 5F t 127 7F
e
>

ahmed_thakur@hotmail.com, 0300-8268885 Page 9
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

## ASCII and Unicode

ASCII (American Standard Code for Information Interchange)is a 7-bit character code that was
introduced by American National Standards Institute (ANSI) and is used by most U.S. personal and
workstation computers.

Acronym for American Standard Code for Information Interchange. A coding scheme using 7 or 8
bits that assigns numeric values to up to 256 characters, including letters, numerals, punctuation

R
marks, control characters, and other symbols. ASCII was developed in 1968 to standardize data
transmission among disparate hardware and software systems and is built into most minicomputers
and all PCs. ASCII is divided into two sets: 128 characters (standard ASCII) and an additional 128

KU
(extended ASCII).

EBCDIC (Extended Binary Coded Decimal Interchange Code) was developed by IBM for use on their
mainframe computers.

Unicode is a character coding system designed to support the worldwide interchange and display

A
of written texts of diverse languages by providing a unique number for every character.

A 16-bit character encoding standard developed by the Unicode Consortium between 1988 and
1991. By using two bytes to represent each character, Unicode enables almost all of the written
languages of the world to be represented using a single character set. (By contrast, 8-bit ASCII is not
TH
capable of representing all of the combinations of letters and diacritical marks that are used just
with the Roman alphabet.) Approximately 39,000 of the 65,536 possible Unicode character codes
have been assigned to date, 21,000 of them being used for Chinese ideographs. The remaining
combinations are open for expansion.

 Express a denary number in Binary Coded Decimal (BCD) and vice versa

ED

1. 45
4 5
0100 0101
= 01000101

2. 98  ?
HM

9 8
1001 1000
= 10011000

## BCD to Decimal Number

1. 01010100
0101 0100
5 4
=54
A

2. 01100011
0110 0011
6 3
=63

http://www.miniwebtool.com/bcd-to-decimal-converter/
http://www.miniwebtool.com/decimal-to-bcd-converter/

ahmed_thakur@hotmail.com, 0300-8268885 Page 10
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

##  Practical applications where BCD is used

Binary-coded Decimal or BCD is a way of representing a decimal number as a string of bits suitable
for use in electronic systems. Rather than converting the whole number into binary, BCD splits the
number up into its digits and converts each digit to 4-bit binary.

## Thus, for example, 345 becomes

R
0011 0100 0101
This is 3 digits longer than the real binary equivalent of 345, 101011001, but it has several advantages

KU
 It can easily be used to drive displays, as each digit is encoded separately.
 It allows each conversion to decimal; true binary to decimal conversion is difficult and gets
increasingly difficult as the number gets longer.
 It allows easy scaling by factors of 10

A