+ All Categories
Home > Education > Application of bases

Application of bases

Date post: 10-Feb-2017
Category:
Upload: abdur-rehman-usmani
View: 124 times
Download: 0 times
Share this document with a friend
18
Transcript
Page 1: Application of bases
Page 2: Application of bases

Application of Bases

o Decimal Numberso Base 10 systems

oexpresses a number as a string of digits in which each digit’s position indicates the power of 10 by which it is multiplied.

5,049 = 5· (1,000) + 0· (100) + 4· (10) + 9· (1).Using exponential notation, this equation can be rewritten as5,049 = 5·103 + 0·102 + 4·101 + 9·100.a sum of products of the formd ·10n

Page 3: Application of bases

Bases

o Binary Numberso base 2 notation, or binary notation,

o signals used in modern electronics are always in one of only two states.

od ·2n,

owhere each n is an integer and each d is one of the binary digits (or bits) 0 or 1.

27 = 16 + 8 + 2 + 1= 1·24 + 1·23 + 0·22 + 1·21 + 1·20.=110112

Page 4: Application of bases

Conversion

o Converting a Binary to a Decimal Number– Represent 1101012 in decimal notation.

1101012 = 1·25 + 1·24 + 0·23 + 1·22 + 0·21 + 1·20

= 32 + 16 + 4 + 1= 5310

o Converting a Decimal to a Binary Numbero Represent 209 in binary notation.

20910 = 128 + a smaller number.20910 = 128 + 64 + a smaller number.=128 + 64 + 16 + 1= 1·27 + 1·26 + 0·25 + 1·24 + 0·23 + 0·22 + 0·21 + 1·20.

Page 5: Application of bases

Binary Addition

o Add 11012 and 1112 using binary notation. 12

+ 12

102

1 1 0 12

+ 1 1 12

12

+ 12

+ 12

112

Page 6: Application of bases

Subtraction in Binary Notation

o Add 11012 and 1112 using binary notation. 102

- 12

12

1 1 0 0 02

- 1 01 12

1 1 0 1

Page 7: Application of bases

Two’s Complements and the Computer Representationof Negative Integers

o Given a positive integer a, the two’s complement of a relative to a fixed bit length n is the n-bit binary representation of 2n − a.o (28 − 27)10 = (256 − 27)10 = 22910 = (128 + 64 + 32 + 4 +

1)10 = 111001012

1. 28 − a = [(28 − 1) − a] + 1.2. The binary representation of 28 − 1 is 111111112.

3. Subtracting an 8-bit binary number a from 111111112 just switches all the 0’s in a to 1’s and all the 1’s to 0’s. (The resulting number is called the one’s complement of the given number.)

Page 8: Application of bases

Two’s Complements and the Computer Representationof Negative Integers

o To find the 8-bit two’s complement of a positive integer a that is at most 255:1. Write the 8-bit binary representation for a.2. Flip the bits (that is, switch all the 1’s to 0’s and

all the 0’s to 1’s).3. Add 1 in binary notation.

Page 9: Application of bases

Two’s Complements and the Computer Representationof Negative Integers

o Find the 8-bit two’s complement of 19.1. Write the 8-bit binary representation for 19,2. Switch all the 0’s to 1’s and all the 1’s to 0’s, and add 1.3. 1910 = (16 + 2 + 1)10 = 000100112

4. Flip the bits→111011005. add→1 11101101

o To check this result, note that111011012 = (128 + 64 + 32 + 8 + 4 + 1)10 = 23710 = (256 − 19)10

= (28 − 19)10, which is the two’s complement of 19.

Page 10: Application of bases

Two’s Complements and the Computer Representationof Negative Integers

o To add two integers in the range −128 through 127 whose sum is also in the range −128 through 127:

o Convert both integers to their 8-bit representations (representing negative integers by using the two’s complements of their absolute values).

o Add the resulting integers using ordinary binary addition.o Truncate any leading 1 (overflow) that occurs in the 28th

position.o Convert the result back to decimal form (interpreting 8-

bit integers with leading 0’s as nonnegative and 8-bit integers with leading 1’s as negative).

Page 11: Application of bases

Two’s Complements and the Computer Representationof Negative Integers

o compute 72 − 54.o =72+(-54)

Page 12: Application of bases

Hexadecimal Notation

o Hexadecimal notation is also called base 16 notation.

o Any integer can be uniquely expressed as a sum of numbers of the formo d ·16n,

owhere each n is a nonnegative integer and each d is one of the integers from 0 to 15.

o The integers 10 through 15 are represented by the symbols A, B, C, D, E, and F.

Page 13: Application of bases

Hexadecimal Notation

Page 14: Application of bases

Converting from Hexadecimal to Decimal Notation

o Convert 3CF16 to decimal notation.

Page 15: Application of bases

Converting from Hexadecimal to Binary Notation

o To convert an integer from hexadecimal to binary notation:1. Write each hexadecimal digit of the integer in 4-

bit binary notation.2. Juxtapose the results.

Page 16: Application of bases

Converting from Hexadecimal to Binary Notation

o Convert B09F16 to binary notation.B16 = 1110 = 10112, 016 = 010 = 00002, 916 = 910 = 10012, and F16 = 1510 =11112. Consequently,

B 0 9 F1011 0000 1001 1111and the answer is 10110000100111112.

Page 17: Application of bases

Converting from Binary to Hexadecimal Notation

o To convert an integer from binary to hexadecimal notation:1. Group the digits of the binary number into sets

of four, starting from the right and adding leading zeros as needed.

2. Convert the binary numbers in each set of four into hexadecimal digits. Juxtapose those hexadecimal digits

Page 18: Application of bases

Converting from Binary to Hexadecimal Notation

o Convert 1001101101010012 to hexadecimal notation.

0100 1101 1010 1001.4 D A 9Then juxtapose the hexadecimal digits.4DA916


Recommended