computers numbering systems

11
Computers – Numbering Systems The Binary System This is a numbering system to the base of two, meaning that it only has two digits 0 and 1. The binary system is the base numbering system used in computer and digital logic control systems. Binary numbers are written as a sequence of zero’s and one’s, where: 0101; 1000; 1001 are examples of four-bit binary numbers. Weighting Each column in the binary number represents a denary number as shown below and doubles with each column. This is called the ‘weighting’ of the numbering system. Each 1 or 0 multiplies a successive power of 2. 8 4 2 1 LSB MSB 2 3 2 2 2 1 2 0 Bin 1 1 0 1 = (1x8) + (1x4) + (0x2) + (1x1)= 13d

Upload: sld1950

Post on 18-May-2015

576 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Computers   numbering systems

Computers – Numbering SystemsThe Binary System

This is a numbering system to the base of two, meaning that it only has two digits 0 and 1.

The binary system is the base numbering system used in computer and digital logic control systems.

Binary numbers are written as a sequence of zero’s and one’s, where: 0101; 1000; 1001 are examples of four-bit binary numbers.

Weighting

Each column in the binary number represents a denary number as shown below and doubles with each column.

This is called the ‘weighting’ of the numbering system.

Each 1 or 0 multiplies a successive power of 2.

8 4 2 1

LSBMSB23 22 21 20

Bin 1 1 0 1 = (1x8) + (1x4) + (0x2) + (1x1)= 13d

Page 2: Computers   numbering systems

Computers – Numbering SystemsThe Hexadecimal System

Numbers in the binary system tend to get very long, the hex system is more compact and less prone to error.

Each column represents a successive power of sixteen (base 16). Hex symbols 0 – 9 for decimal 0 – 9 and A to F for decimal 10 to 15.

256 16 1

162 161 160

Hex 2 3 4 = (2x256) + (3x16) + (4x1) = 564d

Decimal Binary Hex

101

(10)

100

(1)

24

(16)

23

(8)

22

(4)

21

(2)

20

(1)

161

(16)

160

(1)

0 7 0 0 1 1 1 0 7

1 0 0 1 0 1 0 0 A

1 2 0 1 1 0 0 0 C

1 5 0 1 1 1 1 0 F

2 7 1 1 0 1 1 1 8

Page 3: Computers   numbering systems

Computers – Numbering SystemsThe Hexadecimal System

To write a binary number in hexadecimal group the number into four-bit groups beginning with the LSB and write the hex equivalent of each group.

Example

Decimal 245 =

11110101

Group into four bits, = 1111

0101

Hex = F

5

Decimal 245 = F5 (Hex)

The Octal System

A base-8 system from an early era, used during the development of the first computer systems and is not commonly used these days.

Although it does not require the extra symbols (A-F “hex”) it is extremely awkward when applied to byte-organised words of today’s computer systems.

Page 4: Computers   numbering systems

BINARY CODED DECIMAL (BCD)

By converting (encoding) each decimal digit into a four-bit binary group we obtain a system called Binary Coded Decimal (BCD).

This system is ideal for use when we wish to display a decimal digit from its binary equivalent eg digital displays.

Each four-bit group is binary weighted and represents a single digit.

Computers – Numbering Systems

Example

Decimal 245 = 2 4 5

BCD = 0010 0100 0101

Page 5: Computers   numbering systems

Computers – Numbering Systems

2. State the decimal equivalents represented by the binary numbers shown below,

a) 01100101, b) 10110011, c) 10111101.

Assessment

1. Write down the binary equivalents for denary numbers 0 to 12, 28, 32 and 64.

3. State the hexadecimal equivalents for the denary numbers shown below,

a) 8, b) 12, c) 18, d) 28.

4. Convert the binary numbers in question 2 to their hexadecimal equivalents.

5. Convert the binary numbers in question 2 to their BCD equivalents.

Page 6: Computers   numbering systems

ASCII CODE

This is the American Standard Code for Information Interchange.

It is a method of coding alphabetic, numeric and punctuation characters into groups of 7-bits.

Computers – Coding Systems

Char Hex Dec Char Hex Dec

A 41H 65 a 61H 97

B 42H 66 b 62H 98

C 43H 67 c 63H 99

0 30H 48 \ 5CH 92

1 31H 49 ] 5DH 93

2 32H 50 < 3CH 60

Page 7: Computers   numbering systems

GRAY CODE

The Gray code is used for mechanical shaft-angle encoders, the feature of this code is that only one bit changes in going from one state to the next.

This method prevents errors, since there is no way of guaranteeing that all bits will change simultaneously at the boundary between two encoded states.

Computers – Coding Systems

Position Gray Code Position Gray Code

0 0000 8 1100

1 0001 9 1101

2 0011 10 1111

3 0010 11 1110

4 0110 12 1010

5 0111 13 1011

6 0101 14 1001

7 0100 15 1000

D0

D1

D2

D3

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 position

LED’s

Page 8: Computers   numbering systems

2’s COMPLEMENT

The “2’s complement” is the method most widely used for integer computation in electronic systems.

To obtain a negative number (2’s complement) first complement each bit of the positive number then add 1.

Computers – Arithmetic Operations

Check this by adding the original positive number to the 2’s complement representation.

The result should be zero, since the 2’s complement changes the sign of the original positive number.

Example

Decimal 5 = 0101

1’s complement = 1010

+1 (2’s complement) = 1011

Page 9: Computers   numbering systems

Using the 2’s Complement

Subtract B from A, take the 2’s complement of B (create a negative of B) then add this to A.

Computers – Arithmetic Operations

Example 5 - 2 = 5 + (-2)

2 = 0010

1’s complement = 110

+1 (2’s complement) = 1110

5 = 0101

Add = 0011 = 3

Page 10: Computers   numbering systems

Computers – Data Systems

BITS to GIGABYTES

The bit is short for binary digit and has two values (0 or 1)

When four binary bits are grouped together they form a nybble, ‘0110’ and ‘1110’.

When two nibbles, (eight binary bits) are grouped together they form a byte,‘10110101’ and ‘00110111’.

A word is the term used to represent the unit of data in a particular system.In an eight bit system the word contains eight bits.

Personal computers today use 32 and 64 bit words while pic’s and micro-controller’s and Z80cpu systems use four and eight bit words.

Page 11: Computers   numbering systems

Computers – Data Systems

BITS to GIGABYTES – Common Units of Measure

Kilobyte (kB) – Describes the data storage capacity of small systems e.g. memory capacity for micro-controllers and size of data files.

1kB = 1024 bytes (210 bytes).

Megabyte (MB) – Describes the data storage capacity of memory devices, image files (bitmaps).

1MB = 1024 kB (220 bytes).

Gigabyte (GB) – Describes the data storage capacity of hard drives, CD/DVD data storage devices. The gigabyte is the largest unit of capacity in use at present.

1GB = 1024 MB (230 bytes).