|Views: 1,699
|Likes: 13

Published by senior_buen

See more

See less

1

Bangkok University

Number System, Operation and Code

ThidaratTawsookThidarat.t@bu.ac.th

B an gk ok U ni v er si t y

2

ContentContent

Decimal Number

Binary, Hexadecimal, Octal Number

Binary Addition

Binary Subtraction

Code

B an gk ok U ni v er si t y

3

The position of each digitin aweighted number systemis
assigned aweight based on the baseor radix of thesystem. The radix of decimal numbers is ten, becauseonly ten symbols (0 through 9) are used to represent anynumber.

SummarySummarySummary

The column weights of decimal numbers arepowers of ten that increase from right to left beginningwith 10

0

=1:

Decimal Numbers

…10

5

10

4

10

3

10

2

10

1

10

0

.For fractional decimal numbers, the columnweights are negative powers of ten that decrease from leftto right:10

2

10

1

10

0

.10

-1

10

-2

10

-3

10

-4

…

B an gk ok U ni v er si t y

4

SummarySummarySummary

Decimal Numbers

Express the number 480.52 as the sum of values of eachdigit.

(9

x

10

3

) + (2

x

10

2

) + (4

x

10

1

) + (0

x

10

0

)or9 x 1,000 + 2 x 100 + 4 x10 + 0 x 1Decimal numbers can be expressed as the sum of theproducts of each digit times the column value for thatdigit. Thus, the number 9240 can be expressed as

480.52 =(4

x

10

2

) + (8

x

10

1

) + (0

x

10

0

) + (5

x

10

-1

) +(2

x

10

-2

)

B an gk ok U ni v er si t y

5

SummarySummarySummary

Binary Numbers

For digital systems, the binary number system is used.Binary has a radix of two and uses the digits 0 and 1 torepresent quantities.The column weights of binary numbers arepowers of two that increase from right to left beginningwith 2

0

=1:…2

5

2

4

2

3

2

2

2

1

2

0

.For fractional binary numbers, the columnweights are negative powers of two that decrease fromleft to right:2

2

2

1

2

0

.2

-1

2

-2

2

-3

2

-4

…

B an gk ok U ni v er si t y

6

SummarySummarySummary

Binary Numbers

A binary counting sequence fornumbers from zero to fifteen is shown.

0 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 110 1 0 1 011 1 0 1 112 1 1 0 013 1 1 0 114 1 1 1 015 1 1 1 1

DecimalNumberBinaryNumber

Notice the pattern of zeros and onesin each column.

Counter Decoder1 0 1 0 1 0 1 00 10 1 1 0 0 1 1 00 00 0 0 1 1 1 1 00 00 0 0 0 0 0 0 10 1

Digital counters frequently have thissame pattern of digits:

2

B an gk ok U ni v er si t y

7

SummarySummarySummary

Binary Conversions

The decimal equivalent of a binary number can bedetermined by adding the column values of all of the bitsthat are 1 and discarding all of the bits that are 0.Convert the binary number 100101.01 todecimal.Start by writing the column weights; then addthe weights that correspond to each 1 in thenumber.

2

5

2

4

2

3

2

2

2

1

2

0

. 2

-1

2

-2

32 16 8 4 2 1 . ½¼1 0 0 1 0 1. 0 132 +4 +1 +¼=37¼32 +4 +1 +0.25 =37.25

B an gk ok U ni v er si t y

8

SummarySummarySummary

Binary Conversions

Convert the binary number 10010.1011 todecimal.Start by writing the column weights; then addthe weights that correspond to each 1 in thenumber.

2

4

2

3

2

2

2

1

2

0

. 2

-1

2

-2

2

-3

2

-4

16 8 4 2 1 . 0.5 0.25 0.125 0.06251 0 0 1 0 . 1 0 1 116 +2 +0.5 +0.125 +0.0625 =18.6875

B an gk ok U ni v er si t y

9

SummarySummarySummary

Binary Conversions

You can convert a decimal whole number to binary byreversing the procedure. Write the decimal weight of each column and place 1’s in the columns that sum to thedecimal number.Convert the decimal number 49 to binary.The column weights double in each position tothe right. Write down column weights until thelast number is larger than the one you want toconvert.

2

6

2

5

2

4

2

3

2

2

2

1

2

0

.64 32 16 8 4 2 1.0 1 1 0 0 0 1.

B an gk ok U ni v er si t y

10

SummarySummarySummary

You can convert adecimal fraction to binarybyrepeatedly multiplying the fractional results of successivemultiplications by 2. The carries form the binarynumber.Convert the decimal fraction 0.1875 to binary byrepeatedly multiplying the fractional results by 2.0.1875

x

2 =0.375carry =0
0.3750

x

2 =0.750carry =0
0.7500

x

2 =1.500carry =1
0.5000

x

2 =1.000carry =1
Answer =.0011

(for five significant digits)

MSB

Binary Conversions

Stop

B an gk ok U ni v er si t y

11

100110

SummarySummarySummary

You canconvert decimal to any other baseby repeatedlydividing by the base. For binary, repeatedly divide by 2:Convert the decimal number 49 to binary byrepeatedly dividing by 2.You can do this by “reverse division”and theanswer will read from left to right. Putquotients to the left and remainders on top.49 2

Decimalnumberbase

24

remainderQuotient

126310

Continue until thelast quotient is 0

Answer:

Binary Conversions

B an gk ok U ni v er si t y

12

Checkup1

Convert the following decimal numbers to binary

19

45

5.3125See Solution in Page 53-54

Convert the following binary to decimal number

1101101

0.1011See Solution in Page 50-51

110.11

3

B an gk ok U ni v er si t y

13

SummarySummarySummary

Hexadecimal Numbers

Hexadecimal uses sixteen charactersto represent numbers: the numbers 0through 9 and the alphabeticcharacters A through F.

01234567891011121314150123456789ABCDEF0000000100100011010001010110011110001001101010111100110111101111

DecimalHexadecimalBinary

Large binary number caneasily be converted to hexadecimalbygrouping bits 4at a time andwriting the equivalent hexadecimalcharacter.

Express 1001 0110 0000 1110

2

inhexadecimal:Group the binary number by 4-bits starting from the right. Thus,960E

B an gk ok U ni v er si t y

14

SummarySummarySummary

Hexadecimal Numbers

Hexadecimal is a weighted numbersystem. The column weights arepowers of 16, which increase fromright to left.

.

1 A 2 F

16

6703

10

Column weights

16

3

16

2

16

1

16

0

4096 256 16 1

.

{

Express 1A2F

16

in decimal.

Start by writing the column weights:4096 256 16 1

1(4096) + 10(256) +2(16) +15(1) =

01234567891011121314150123456789ABCDEF0000000100100011010001010110011110001001101010111100110111101111

DecimalHexadecimalBinary

B an gk ok U ni v er si t y

15

Checkup2

Convert the following decimal numbers to hexadecimal number

650

10

See Solution in Page 76

2606.1015625

10

See Solution in Page

๖

Convert the following hexadecimal numbers to decimal number

E5

16

See Solution in Page 75

D3C.2F

16

See Solution in Page

๙

Convert the following hexadecinalnumbers to binary number

10A4

16

CF8E

16

See Solution in Page 74

A69.238

16

See Solution in Page

๑๓

Convert the following binary numbers to octal number

100101

2

1100101001010111

2

See Solution in Page 74

11111100001101.100011

2

See Solution in Page

๑๓

B an gk ok U ni v er si t y

16

SummarySummarySummary

Octal Numbers

Octal uses eight characters thenumbers 0 through 7 to representnumbers. There is no 8 or 9character in octal.

01234567891011121314150123456710111213141516170000000100100011010001010110011110001001101010111100110111101111

DecimalOctalBinary

Binary number can easily beconverted to octal bygrouping bits 3at a time and writing the equivalentoctal character for each group.

Express 1 001 011 000 001 110

2

inoctal:Group the binary number by 3-bitsstarting from the right. Thus,113016

8

B an gk ok U ni v er si t y

17

SummarySummarySummary

Octal Numbers

Octal is also a weighted numbersystem. The column weights arepowers of 8, which increase fromright to left.

.

3 7 0 2

8

1986

10

Column weights

8

3

8

2

8

1

8

0

512 64 8 1

.

{

Express 3702

8

in decimal.

Start by writing the column weights:512 64 8 1

3(512) + 7(64) +0(8) +2(1) =

01234567891011121314150123456710111213141516170000000100100011010001010110011110001001101010111100110111101111

DecimalOctalBinary

B an gk ok U ni v er si t y

18

Checkup3

Convert the following decimal numbers to octal number

359See Solution in Page 80

415.65625See Solution in Page

๕

Convert the following octal numbers to decimal number

2374See Solution in Page 80

15.21

Convert the following octal numbers to binary number

25

7526See Solution in Page 81

524.61See Solution in Page

๑๑

Convert the following binary numbers to octal number

100101

101111001See Solution in Page 82

11101001000.01011See Solution in Page

๑๑

Filters

1 hundred reads

1 thousand reads

Carla Gonzales Dela Cruz liked this

GC786 liked this

ccny07 liked this

Anand liked this

krantir12389 liked this

zebashamshi liked this

zebashamshi liked this

Graycode liked this

scribd