Chapter 3 - Base Number

download Chapter 3 - Base Number

of 13

Transcript of Chapter 3 - Base Number

  • 7/27/2019 Chapter 3 - Base Number

    1/13

    BASE NUMBER

    There is much other numbering system - mostly associated with computers. These include:

    Binary Octal Hexadecimal Binary Coded Decimal (BCD)

    THE DECIMAL SYSTEM

    This is the system in everyday use; there are 10 digits (0 to 9 inclusive) so it has a 'base' of 10.

    EXAMPLE:

    1. Taking the number 7213, it can be written as:(7 x 1000) + (2 x 100) + (1 x 10) + (3 x 1)

    = (7 x 103

    ) + (2 x 102

    ) + (1 x 101) + (3 x 10

    0)

    = 7213

    Each digit is effectively multiplied by a power of 10

    2.

    Note that to write 12.37 in power of 10(1 x 10') + (2 x 10

    0) + (3 x 10

    -1) + (7 x 10

    -2)

    = (10) + (2) + (0.3) + (0.07)

    = 12.37

    Note that 10 0 = 1. ln fact any number to the power of zero = 1

  • 7/27/2019 Chapter 3 - Base Number

    2/13

    BINARY SYSTEM

    Let's look at base-two, or binary, numbers. How would you write, for instance, 12 10 as a binary

    number? You would have to convert to base-two columns, the analogue of base-ten columns. In

    base two, you have 20

    = 1, 21

    = 2, 22

    = 4, 23

    = 8, 24

    = 16, and so forth.

    The first column in base-two math is the units column. But only "0" or "1" can go in the units

    column. When you get to "two", you find that there is no single solitary digit that stands for

    "two" in base-two math. Instead, you put a "1" in the twos column and a "0" in the units

    column, indicating "1 two and 0 ones". The base-ten "two" (210) is written in binary as 102.

    Here is a listing of the first few numbers:

    Decimal

    (base 10)

    Binary

    (base 2)

    0

    1

    2

    3

    4

    5

    67

    8

    9

    10

    11

    12

    13

    14

    15

    16

    0

    1

    10

    11

    100

    101

    110111

    1000

    1001

    1010

    1011

    1100

    1101

    1110

    1111

    10000

    0 ones

    1 one

    1 two and zero ones

    1 two and 1 one

    1 four, 0 twos, and 0 ones

    1 four, 0 twos, and 1 one

    1 four, 1 two, and 0 ones1 four, 1 two, and 1 one

    1 eight, 0 fours, 0 twos, and 0 ones

    1 eight, 0 fours, 0 twos, and 1 one

    1 eight, 0 fours, 1 two, and 0 ones

    1 eight, 0 fours, 1 two, and 1 one

    1 eight, 1 four, 0 twos, and 0 ones

    1 eight, 1 four, 0 twos, and 1 one

    1 eight, 1 four, 1 two, and 0 ones

    1 eight, 1 four, 1 two, and I one

    1 sixteen, 0 eights, 0 fours, 0 twos, and 0 ones

    Converting between binary and decimal numbers is fairly simple, as long as you remember that

    each digit in the binary number represents a power of two.

  • 7/27/2019 Chapter 3 - Base Number

    3/13

    EXAMPLE

    1. Convert 1011001012 to the corresponding base-ten numberList the digits in order, and count them off from the RIGHT, starting with zero:

    Digits : 1 0 1 1 0 0 1 0 1

    Numbering : 8 7 6 5 4 3 2 1 0

    Use this listing to convert each digit to the power of two that it represents:

    (1 x 28

    )+( 0 x 27

    )+ (1 x 26

    )+ (1 x 25

    )+ (0 x 24)+(0 x 2

    3)+ (1 x 2

    2)+ (0 x 2

    1)+ (1 x 2

    0)

    = (1 x 256) + (0 x 128) + (1 x 64) + (1 x 32) + (0 x 16) + ( 0 x 8) + (1 x 4) + (0 x 2) + (1 x 1)

    = 256 + 64 + 32 + 4 + 1

    = 357

    Answer: Then 1011001012 convert to 35710

    Converting decimal numbers to binaries is nearly as simple: just divide by 2.

    2. Convert 35710 to the corresponding binary number.To do this conversion, you need to divide repeatedly by 2, keeping track of the remainders

    as you go. Watch below:

    As you can see, after dividing repeatedly by 2, I ended up with these remainders

    3572

    11782

    0892

    1442

    0222

    0112

    152

    122

    01

    R

    R

    R

    R

    R

    R

    R

    R

    These remainders tell us what the binary number is. Read the numbers from around the

    outside of the division, starting on top and wrapping your way around the right-hand side.

    As you can see:

    Answer: 35710 converts to 101 1001012

  • 7/27/2019 Chapter 3 - Base Number

    4/13

    BINARY ARITHMETIC

    Arithmetic in binary is much like arithmetic in other numeral systems. Addition, subtraction,

    multiplication, and division can be performed on binary numerals.

    1 Addition

    The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers

    is relatively simple:

    0 + 0 0

    0 + 1 1

    1 + 0 1

    1 + 1 0, carry 1 (since 1 + 1= 0 + 1 x 10 in binary)

    Adding two "1" digits produces a digit "0", while 1 will have to be added to the next column. Thisis similar to what happens in decimal when certain single-digit numbers are added together; if

    the result equals or exceeds the value of the radix (10), the digit to the left is incremented

    5 + 5 0, carry 1 (since 5 + 5 = 0 + 1 x 10)

    7 + 9 6, carry 1 (since 7 + 9 = 6 + 1 x 10)

    This is known as carrying. When the result of an addition exceeds the value of a digit, the

    procedure is to "carry" the excess amount divided by the radix (that is, 10/10) to the left, adding

    it to the next positional value. This is correct since the next position has a weight that is higher

    by a factor equal to the radix. Carrying works the same way in binary.

    EXAMPLE

    1 1 1 1 1 (carried digits)

    0 1 1 0 1

    + 1 0 1 1 1

    = 1 0 0 1 0 0

    In this example, two numerals are being added together: 011012 (13-decimal) and 101112 (23

    decimal). The top row shows the carry bits used. Starting in the rightmost column, 1 + 1= 10 2.

    The 1 is carried to the left, and the 0 is written at the bottom of the rightmost column. The

    second column from the right is added: 1 + 0 + 1 = 102 again; the list carried and is written at the

    bottom. The third column: 1 + 1 + 1 =112. This time ,a 1 is carried, and a 1 is written in the

    bottom row. Proceeding like this gives the final answer 1001002 (36 decimal)

  • 7/27/2019 Chapter 3 - Base Number

    5/13

    2 Subtraction

    Subtraction works in much the same way:

    0 0 0

    0 1 1, borrow 1

    1 0 1

    1 1 0

    Subtracting a "1" digit from a "0" digit produces the digit 1, while 1 will have to be subtracted

    from the next column. This is known as borrowing. The principle is the same as for carrying.

    When the result of a subtraction is less than 0, the least possible value of a digit, the procedure

    is to "borrow" the deficit divided by the radix (that is, 10/10) from the left, subtracting it from

    the next positional value.

    EXAMPLE

    * 1 * * * (carried digits)

    1 1 0 1 1 1 0

    - 1 0 1 1 1

    = 1 0 1 0 1 1 1

    Subtracting a positive number is equivalent to adding a negative number of equal absolute

    value; computers typically use two's compliment notation to represent negative values' This

    notation eliminates the need for a separate "subtract" operation. A - B = A +not B +1

    3 Multiplication

    Multiplication in binary is similar to its decimal counterpart. Two numbers A and B can be

    multiplied by partial products: for each digit in B, the product of that digit-in A is calculated and

    written on a new line, shifted leftward so that its rightmost digit lines up with the digit in B that

    was used. The sum of all these partial products give the final result.

    Since there are only two digits in binary, there are only two possible outcomes of each partial

    multiplication:

    lf the digit in B is 0, the partial product is also 0. lf the digit in B is 1, the partial product is equal to A

  • 7/27/2019 Chapter 3 - Base Number

    6/13

    EXAMPLE

    1. For example, the binary numbers 1011 and 1010 are multiplied as follow:

    2. Binary numbers can also be multiplied with bits after a binary point:

    4 Division

    Binary division is again similar to its decimal counterpart:

    Here, the divisor is 1012, or 5 decimal, while the dividend is 110112, or 27 decimal. The

    procedure is the same is that of decimal long division; here, the divisor 1012 goes into the first

    three digits 1102 of the dividend one time, so a "1" is written on the top line. This result is

    multiplied by the divisor, and subtracted from the first three digits of the dividend; the next digit

    (a "1") is included to obtain a new three-digit sequence:

  • 7/27/2019 Chapter 3 - Base Number

    7/13

    EXAMPLE

    The procedure is then repeated with the new sequence, continuing until the digits in the

    dividend have been exhausted.

    Thus, the quotient of 110112 divided by 1012 is 1012, as shown on the top line, while the

    remainder, shown on the bottom line, is 102. ln decimal, 27 divided bys is 5, with a

    remainder of 2.

    OCTAL SYSTEM

    An older computer base system is "octal" or base-B number system. The digits in octal are

    0, 1,2,3,4,5,6 and 7. The value "eight" is written as 1 eight and 0 ones or 108

    DECIMAL TO OCTAL CONVERSION

    Method used division by 8:-

    Divide the quotient by eight and record the remainder. Repeat step until the quotient is equal to zero (0) The remainder is read from bottom to top

  • 7/27/2019 Chapter 3 - Base Number

    8/13

    EXAMPLE : Convert 35910 to Octal:

    Read from bottom to top

    Therefore, 35910 = 5478

    OCTAL TO DECIMAL CONVERSION

    Method used: sum the digits after each has been multiplied by its associated weight

    EXAMPLE : Convert 2378 to Decimal

    BINARY TO OCTAL CONVERSION

    Method used : replace each octal digit with the appropriate three-bit binary number

    EXAMPLE : Convert 138 to binary

    Solution = 001 0112

  • 7/27/2019 Chapter 3 - Base Number

    9/13

    OCTAL TO BINARY CONVERSION

    Method use : Break the binary digits into groups of three from right/decimal point and convert

    each group into its appropriate octal digit.

    EXAMPLE : Converting (010111)2 to Octal

    Solution: 111 = 7 (LSB)

    010 = 2 (MSB)

    thus, (010111)2=(27)

    HEXADECIMAL SYSTEM

    Hexadecimal describes a base-16 number system. The hexadecimal numbers are 0-9 and then

    use the letters A-F. We show the equivalence of binary, decimal, and hexadecimal numbers in

    the table below.

    Binary Decimal Hexadecimal

    0

    1

    10

    11

    100

    101

    110111

    1000

    1001

    1010

    1011

    1100

    1101

    1110

    1111

    0

    1

    2

    3

    4

    5

    67

    8

    9

    10

    11

    12

    13

    14

    15

    0

    1

    2

    3

    4

    5

    67

    8

    9

    A

    B

    C

    D

    E

    F

    DECIMAL TO HEXADECIMAL CONVERSION

    Method used: division by 16:

    Divide the quotient by sixteen and record the remainder Repeat step until the quotient is equal to zero (0). The remainder is read from bottom to top

  • 7/27/2019 Chapter 3 - Base Number

    10/13

    EXAMPLE : 123410 to Hexadecimal

    SOLUTION :

    Read from bottom to top

    Therefore, 1234 10 = 4D2H, or 4D216

    HEXADECIMAL TO DECIMAL CONVERSION

    Method use: sum the digits after each has been multiplied by its associated weight

    EXAMPLE : Convert 4D216 to Decimal

    SOLUTION :

  • 7/27/2019 Chapter 3 - Base Number

    11/13

    HEXADECIMAL TO BINARY CONVERSION AND VISE VERSA

    Method use: The easiest wav is to use the table below

    EXAMPLE

    1. Convert F816 to Binary

    Solution: F = 1111

    8 = 1000

    Thus, F816 = 1111 10002

    2. Convert 111010110102 to Hexadecimal

    Solution: Break the binary digits into groups of four from right/decimal point and

    convert each group into its appropriate hex digit

    Thus, 111010110102 = 75A16

  • 7/27/2019 Chapter 3 - Base Number

    12/13

    EXERCISE 5.1 :

    1. Convert the following decimal numbers to binary number

    a. 8410

    b. 12410

    c. 410

    2. Convert the following decimal numbers to octal numbers:

    a. 32410

    b. 7710

    c. 8510

    3. Express the following decimal numbers to hexadecimal numbers

    a. 17810

    b. 5510

    c. 20710

    4. Convert the binary numbers to decimal numbers

    a. 101112

    b. 1112

    c. 111012

    5. What would the following octal numbers be in decimal numbers?

    a. 14408

    b. 3728

    c. 748

    6. Convert the hexadecimal numbers to decimal numbers

    a. 3CE16

    b. A0316

    c. 5616

  • 7/27/2019 Chapter 3 - Base Number

    13/13

    7. Calculate the octal numbers equivalent of the following binary numbers

    a. 1011112

    b. 1010102

    c. 110112

    8. Convert the following octal numbers to binary numbers:

    a. 13168

    b. 26548

    c. 5278

    9. Express the following numbers, which are in hexadecimal numbers, as octal numbers

    a. 2CD16b. 7A816

    c. 4EF 16

    10. Determine the value of the following binary numbers, using the binary method addition

    a. 111 + 101

    b. 1111 + 1111

    c. 10010 + 101 10