+ All Categories
Home > Documents > NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number...

NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number...

Date post: 02-Apr-2015
Category:
Upload: sheldon-newingham
View: 223 times
Download: 4 times
Share this document with a friend
49
NUMBER SYSTEMS
Transcript
Page 1: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

NUMBER SYSTEMS

Page 2: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

The BASE of a number system

Determines the number of digits available

In our number system we use 10 digits: 0-9

The base in our system is 10

It is called decimal or denary

Page 3: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

The BASE of a number system

Computers are bi-stable devices A bi-stable device has only two possible

states: ON or OFF Hence a base 2 number system is

enough for such devices A base 2 number system is called

binary The 2 possible digits are 0 and 1

Page 4: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

The BASE of a number system

An other number system used with

computers is Hexadecimal

The base for this system is 16

The 16 possible digits are 0 – 9 and A - F

Page 5: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

The BASE of a number system

System Base Digits used

Decimal base 10e.g. 510

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

Binary base 2e.g. 102

0, 1

Hexadecimal

base 16e.g.

3C16

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Page 6: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Place values The position of each number within a

series of numbers is very important

The position of the number determines

how large it is

All number bases have their place values

Page 7: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Place values

In base 10, the place values are as follows:

106 105 104 103 102 101 100

1 000 000 100 000 10 000 1000 100 10 1

Values go up in powers of 10 as you move from left to right

Page 8: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Place values

In base 2, the place values are as follows:

Values go up in powers of 10 as you move from left to right.

29 28 27 26 25 24 23 22 21 20

512 256 128 64 32 16 8 4 2 1

Page 9: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary to Decimal Conversion

To convert binary numbers to decimal we need to follow these four steps:

1.Write down the place values, starting from the

right hand side

2.Write each binary digit under its place value

3.Multiply each binary digit by its place value

4.Add up the total number

Page 10: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary to Decimal ConversionExample Convert the binary number 10101 to decimal.

24 23 22 21 20

Step 1 Place values

16 8 4 2 1

Step 2 Binary digits

1 0 1 0 1

Step 3 1 × 16 = 16

0 × 8 = 0

1 × 4 = 4

0 × 2 = 0

1 × 1 = 1

Step 4 Decimal 16 + 0 + 4 + 0 + 1 = 21

Answer: 101012 = 2110

Page 11: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary Conversion

To convert a decimal number to binary

1.Successively divide the decimal number by 2

and record the remainder

2.Use the numerator for the next division until

the result of the division is 0

3.The remainder (1 or 0) of each division

makes up the binary number

Page 12: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary Conversion

To convert a decimal number to binary

1. The remainder of the first division gives the LEAST

significant bit

2. The remainder of the next division gives the NEXT

bit etc.

3. This method produces the bits in reverse order -

reading down the way gives the bits in order of

right to left

Page 13: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary ConversionExampleConvert 3710 in binary

2 37

2 18 with a remainder of 1

2 9 with a remainder of 0

2 4 with a remainder of 1

2 2 with a remainder of 0

2 1 with a remainder of 0

0 with a remainder of 1Answer : 3710 = 1001012

Page 14: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary Conversion

An alternative method is to use the place values. To convert a decimal number to binary follow these steps:

1. Write down the place values up to the one which is just greater than the decimal number we need to convert

Page 15: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary Conversion

Let us consider the decimal number 37, we would need to write down the place values up to 64

26 25 24 23 22 21 20

Place values 64 32 16 8 4 2 1

Page 16: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary Conversion

2. Work through the place values deciding on whether to place a 1 or a 0 under the place value

Page 17: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary Conversion

Since 37 is less than 64 we write a 0 under the 64. We would need a 32 so we write a 1 under the 32

26 25 24 23 22 21 20

Place values 64 32 16 8 4 2 1

Binary number

0 1

Page 18: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Binary ConversionThis would leave us with 37 – 32 = 5. Now we are left with 5 to distribute under the other place values. Since 5 is less than 16 and 8 we write a 0 under both. We can now place a 1 under 4. This leaves us with 5 – 4 = 1. Hence we put a 0 under 2 and a 1 under 1.

26 25 24 23 22 21 20

Place values 64 32 16 8 4 2 1

Binary number

0 1 0 0 1 0 1

So 3710 = 1001012

Page 19: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

The Hexadecimal (Hex) number system

Base 16 16 symbols: 0 – 9 & A – F Place values increase in powers of 16

The advantage of the hexadecimal system is its usefulness in converting directly from a 4-bit binary number

Page 20: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Equivalent numbers in different bases

Decimal

Binary

Hex

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

8 1000 8

9 1001 9

Decimal

Binary

Hex

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

Page 21: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Hex to Decimal Conversion

To convert Hex numbers to decimal we need to follow these four steps:

1.Write down the place values, starting from the

right hand side

2.Write each hex digit under its place value

3.Multiply each hex digit by its place value

4.Add up the total number

Page 22: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Hex to Decimal Conversion

ExampleConvert 3CD16 to its decimal equivalent.

162 161 160

Step 1 Place value 256 16 1

Step 2 Hex 3 C D

Step 3 256 × 3= 768

16 × 12= 192

1 × 13= 13

Step 4 Decimal 768 + 192 + 13 = 973

Answer: 3CD16 = 97310

Page 23: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

To convert a decimal number to hex Successively divide the decimal number

by 16 and record the remainder Use the numerator for the next division

until the result of the division is 0 The remainder of each division makes

up the hex number

Page 24: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

Example 1Convert 4110 to hex

Answer : 4110 = 2916

16 41

16 2 with a remainder of 9

0 with a remainder of 2

Page 25: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

Example 3Convert 10910 to hex

Answer : 10910 = 6 1316

= 6D16

16 109

16 6 with a remainder of 13

0 with a remainder of 6

Page 26: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

An alternative method is to use the place values. To convert a decimal number to hex follow these steps:

1. Write down the place values up to the one which is just greater than the decimal number we need to convert

Page 27: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

Let us consider the decimal number 356, we would need to write down the place values up to 4096

163 162 161 160

Place values 4096 256 16 1

Page 28: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

2. Work through the place values deciding on weather to place a 0 or a value from 1 - 15 under the place value.

Page 29: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

Since 356 is less than 4096 we write a 0 under the 4096. We would need a 256 so we write a 1 under the 256.

163 162 161 160

Place values 4096 256 16 1

Hex number 0 1

Page 30: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Decimal to Hex Conversion

This would leave us with 356 – 256 = 100. Now we are left with 100 to distribute under the other place values. Since 100 ÷ 16 =6 r 4 we write a 6 under 16. This leaves us with 4 ones. Hence we put a 4 under 1.

163 162 161 160

Place values 4096 256 16 1

Hex number 0 1 6 4So 35610 = 16416

Page 31: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary to Hex Conversion

To convert numbers from binary to hex and vice versa, we need to use the conversion table shown below

Binary

Hex

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

Binary

Hex

1011 B

1100 C

1101 D

1110 E

1111 F

Binary

Hex

0110 6

0111 7

1000 8

1001 9

1010 A

Page 32: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary to Hex Conversion

For each digit in the hex number, write down the equivalent 4-bit binary digit.

ExampleConvert C316 to its binary equivalent

Answer : C316 = 110000112

Hexadecimal C 3

Binary 1100 0011

Page 33: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Hex to Binary Conversion

Divide the binary number into 4-bit groups starting from the right (LSB). If we end up with a group of less than 4 bits on the left, add 0s to fill up the required places. Then translate each group into its equivalent hexadecimal number below.

Page 34: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Hex to Binary Conversion

ExampleConvert 10111010102 to hexadecimal

Answer : 10111010102 = 2EA16

Binary 0010 1110 1010

Hexadecimal 2 E A

Page 35: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary Arithmetic

Page 36: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Addition of Binary Numbers

13  +

17

30

Note:

3 + 7 = 10 which we write as 0 carry 1.

0 1 1 0 1  +

1 0 0 0 1

1 1 1 1 0

Similarly in binary:

1 + 1 =  0 carry 1.

Page 37: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Addition of Binary Numbers

13  +

17

  1

31 Note:

3 + 7 + 1= 11 which we write as 1 carry 1.

0 1 1 0 1  +

1 0 0 0 1

0 0 0 0 1

1 1 1 1 1

Similarly in binary:

1 + 1 + 1 =  1 carry 1.

Page 38: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Numeric Overflow

13  +

17

11

41

Note:

The number 41 cannot be represented using 5 bits since with 5 bits we can represent the range from 0 to 31.

0 1 1 0 1  +

1 0 0 0 1

0 1 0 1 1

0 1 0 0 11

Numeric overflow occurs if a number too large to be represented is encountered.  For example a 5 bit register is used to store the decimal number 41. 

Page 39: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Negative Numbers

Negative numbers can be represented in binary using one of the following ways:

• Sign and Magnitude Codes (SM)

• Two's Complement (2C)

Page 40: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

• The Most Significant Bit is used to represent the sign of the number 

Sign and Magnitude Codes

• The other bits represent the magnitude of the number.  

Page 41: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Example: Sign and Magnitude

Convert 24 to Sign and Magnitude representation using an 8-bit register format.

24In binary

1 1 0 0 0

24Using 7 bits

0 0 1 1 0 0 0

24SM

0 0 0 1 1 0 0 0

O since number is positive

Page 42: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Example: Sign and Magnitude

Convert - 24 to Sign and Magnitude representation using an 8-bit register format.

24In binary

1 1 0 0 0

24Using 7 bits

0 0 1 1 0 0 0

24SM

1 0 0 1 1 0 0 0

1 since number is negative

Page 43: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Two's Complement (2C)

The bits have the same place values as binary numbers. 

However the Most Significant Bit is also used to represent the sign of the number.

Page 44: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Example: Two's Complement

Complement 67 using a 9-bit register

67In binary

0 1 0 0 0 0 0 1 1

Reverse Bits 1 0 1 1 1 1 1 0 0

Add 1 1 0 1 1 1 1 1 0 1

This gives -67

Page 45: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Range for 2C Representation

1-bit register 0 represents 0

1 represents -1

2-bit register

0 0 represents 00 1 represents 11 0 represents -21 1 represents -1

1-bit register -1 , 0

2-bit register -2, -1, 0, 1

3-bit register

0 0 0 represents 00 0 1 represents 10 1 0 represents 20 1 1 represents 3

3-bit register -4, -3, -2, -1, 0, 1, 2, 3

1 0 0 represents -41 0 1 represents -31 1 0 represents -21 1 1 represents -1

Page 46: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Range for 2C Representation

In general an N-bit register can represent binary numbers in the range

- 2N-1 ... + 2N-1- 1.

Page 47: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary SubtractionExample: Subtract 54 from 103

103 - 54 Can be written as 103 + (- 54)

Step 1: Check how many bits you need

Therefore we are going to use 8 bits in both cases.

103 8 bits (range for +ve numbers is 0 …2n-1)

-54 7 bits (range for 2C numbers is 2n-1 to + 2n-1-1)

Page 48: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary Subtraction

Step 2: Convert - 54 to a 2C binary number

-54 1 1 0 0 1 0 1 02

Step 3: Convert 103 to a binary number

103 0 1 1 0 0 1 1 12

Step 4: Add binary 103 to - 54

0 1 1 0 0 1 1 12 +

   1 1 0 0 1 0 1 02

1 0 0 1 1 0 0 0 12

Overflow bit

The 9th bit or overflow bit will be ignored thus the 8-bit answer is correct. 0 0 1 1 0 0 0 12

Page 49: NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.

Binary Multiplication

• Shifting the number left multiplies that number by 10  

Decimal System Binary System

• Shifting the number left multiplies that number by 2 

420 = 42 x 10. 111000 =  11100 x 2


Recommended