comp 411-3, numbr systems

Post on 08-Dec-2015

243 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Number Systems

TRANSCRIPT

NUMBER SYSTEMS

Number Systems

1. Binary Numbers

2. Hexadecimal Numbers

3. Octal Numbers

4. Binary and Hexadecimal Arithmetic

Neil Abalajon

Table of EquivalentsDecimal Binary Hexadecimal Octal

0 0000 0 0

1 0001 1 1

2 0010 2 2

3 0011 3 3

4 0100 4 4

5 0101 5 5

6 0110 6 6

7 0111 7 7

8 1000 8 10

9 1001 9 11

10 1010 A 12

11 1011 B 13

12 1100 C 14

13 1101 D 15

14 1110 E 16

15 1111 F 17

Neil Abalajon

1. Binary Numbers

- a number that has a base of 2.

- the coefficients of the binary number system have only two possible values: 0 and 1.

Representation:

1 1 0 1 1

LSB – Least Significant Bit

MSB – Most Significant Bit

Neil Abalajon

1.1 Decimal-Binary ConversionSteps:

a) Divide the no. by 2’s.

b) If the result has a remainder, indicate a “1” , otherwise, “0” in the right hand portion.

c) Divide the resultant whole no. by 2’s.

d) Repeat steps ( b ) & ( c ) until no. that is being divided by 2 is 1 .

* Binary result is derived by reading from the bottom.

Note: The remainder after each division is used to indicate the coefficient of the Binary no. to be formed.

Neil Abalajon

1.1 Decimal-Binary Conversion

1810 = ?2

182

9 02

4 12

2 02

1 0

1710 = 100102

Remainders

Neil Abalajon

1.2 Binary-Decimal Conversion

Example:

a) 1 1 0 1 2 =

b) 1 1 1 1 2 =

13 10

15 10

Neil Abalajon

1.2 Binary-Decimal Conversion

Solved Example:

a) 1 1 0 1 2 = 13 10

11012 = 1(23)+1(22)+0(21)+1(20)

= 810+ 410+ 010 + 110

= 1310

Neil Abalajon

1.2 Binary-Decimal Conversion

x…11012 = x(2n)…+1(23)+1(22)+0(21)+1(20)

Conversion Formula:

Where n is the number total number of 1’s and 0’s in the binary number.

n Radix is 2

Neil Abalajon

2. Hexadecimal Number System A no. system that has a base, or radix of 16.

16 diff. Symbols are used to represent nos.

The first ten digits (0 to 9) are borrowed from the Decimal no. system

the letters A, B, C, D, E & F are used for digits 10, 11, 12, 13, 14 and 15, respectively.

Example form:

3BAF 16 DEF54 16

Neil Abalajon

2.1 Decimal-Hexadecimal Conversion

Steps:

same procedure in DEC-BIN conversion, except that the number is divided by 16

digit in the remainder is expressed in HEX.

Example:

a) 245 10 =

b) 61 10 =

F516

3D16

Neil Abalajon

2.2 Hexadecimal-Decimal Conversion

Steps:

a) Convert a single HEX no. to its equivalent decimal form. (See Table of Equivalents)

b) Follow the same procedure(formula) in converting BIN-DEC, but change the base number from 2 to 16 and represent each HEX digit with its DEC equivalent

B9F16 = 11(162) + 9(161) + 15(160)

= 81610 + 14410 + 1510

= 297510Neil Abalajon

HEX-DEC Examples:

a) ABC 16 =

b) AB6 16 =

c) 3A6 16 =

d) B9F 16 =

2748 10

2742 10

934 10

2975 10

Neil Abalajon

2.3 Binary-Hexadecimal Conversion

Steps:

a) Break the binary no. into groups of four digits.

b) Convert each group of four digits according to the its corresponding HEX symbol.

c) Read each set of Binary digits starting from the right (LSB).

Example:a) 1 0 1 1 1 0 1 1 2 =

b) 1 0 0 1 0 1 0 1 2 =

c) 1 0 1 1 0 0 0 1 1 0 1 0 1 1 2 =

BB 16

95 16

2C6B 16

Neil Abalajon

3. Octal Number System

A number system that has a base, or radix of 8

Eight diff. Symbols are used to represent numbers. These are 0, 1, 2, 3, 4, 5, 6 and 7.

Example form: 17 8

57 8

Neil Abalajon

3.1 Decimal-Octal Conversion

Steps:

same procedure in DEC-BIN conversion

Decimal no. is divided by 8

Remainder is placed at the right

Division stops if the quotient is less than 8

Example:

a) 153 10 =

b) 82 10 =

231 8

122 8

Neil Abalajon

3.2 Octal-Decimal Conversion

Steps:

same steps used in BIN-DEC, except that 8 is being used instead of 2 as a radix or base.

Example:

a) 17 8 =

b) 1213 8 =

15 10

651 10

Neil Abalajon

3.3 Binary-Octal Conversion

Steps:

a) Group the binary digits into groups of 3.

b) Read each set of binary digits starting from the right (LSB).

Example:

a) 1 1 1 1 1 0 1 1 1 2 =

b) 1 1 0 0 1 1 2 =

c) 1 1 0 1 1 2 =

767 8

63 8

33 8Neil Abalajon

4. Binary and Hexadecimal Arithmetic

Arithmetic between binary and hex numbers can be done by converting them into decimal first, and convert the result back to binary or in hexadecimal as the case may be.

There will be times, however, that such procedure would be time consuming.

It would be faster to operate in binary or hexadecimal directly.

Neil Abalajon

Binary Addition

is performed in the same manner as decimal addition.

• Binary Addition Table:

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 0 Plus a carry over of 1 to the next digit

Neil Abalajon

Binary Subtraction

inverse operation of addition.

• Binary Subtraction Table:

0 – 0 = 0

1 – 0 = 1

1 – 1 = 0

0 – 1 = 1 W/ a borrow of 1 from the next column to the left

Neil Abalajon

2 Cases of Subtraction:

Case 1:

When a small number is being subtracted from a larger number.

Case 2:

When a large number is being subtracted from a smaller number resulting to a negative result (complement of a (-) no.)

Neil Abalajon

Binary Multiplication

is performed in the same manner as in decimal multiplication.

• Binary Multiplication Table:

0 X 0 = 0

1 X 0 = 0

0 X 1 = 0

1 X 1 = 1

Neil Abalajon

Hexadecimal Addition

Rules:

1) Add the first column followed by the second column. From right to left.

2) If the sum of the two digits on the same column is 1510 or less, bring down the corresponding Hex digit.

3) If the sum of is greater than 1510, bring down the amount of the sum that exceeds 1610 & carry a “1” to the next column.

Neil Abalajon

Hexadecimal Subtraction (rules when borrowing)

Rules:

1) Subtract the subtrahend digit from F, then add 1.

2) Add the result to the minuend.

Note: Always add 1 for each column that borrowed from the next column to the left.

Neil Abalajon

BCD Format

Neil Abalajon

Binary Coded Decimal (BCD)

- means that each decimal digit is represented by a binary code of four-bits.

Example:

Convert each of the ff. decimal nos. into their BCD format:

3 9 18 65 321

Neil Abalajon

Solution:

3

0011

9

1001

18

0001 1000

65

0110 0101

321

0011 0010 0001

Neil Abalajon

BCD Format Application

One of the common uses of the BCD format is in 7-segment BCD displays.

0 0 0 00 1 0 10 0 1 00 1 1 1BCD =

Neil Abalajon

BCD Addition

Rules:

1) Add the two numbers, using the rules of binary addition.

2) If a four-bit sum is equal to or less than 9, it is a valid BCD number.

3) If a four-bit sum is greater than 9, or if a carry is generated, it is an invalid result. Add 6 (0110 2) to the 4-bit sum (excess only). If a carry results when 6 is added, simply add the carry to the next 4-bit group.

Neil Abalajon

BCD SubtractionRules:

1) Take the 2’s Complement of the subtrahend and add it to the minuend and disregard the carry in the MSB of the result

2) If the four-bit difference is less than or equal to 9 it is a valid BCD number

3) If a four-bit difference is greater than 9 (in Hex), it is an invalid result. Subtract 6 (0110 2) from each 4-bit group that is in excess of 9 (10012)

Neil Abalajon

Determining whether a number is Positive or

Negative

Neil Abalajon

Positive and Negative Hexadecimal Numbers

8000h is negative because the MSB is “1”.

100h is positive because the MSB is “0”.

7FFFh is

0FFFFh is

0FFFh is

positive

negative

positive

Neil Abalajon

- End of Presentation -

Neil Abalajon

top related