0% found this document useful (0 votes)
124 views4 pages

Horners Convert

The document explains Horner's rule, which is an efficient algorithm for converting numbers between different number bases, such as binary to decimal. It provides examples of using Horner's rule to convert several binary numbers to decimal by multiplying each bit by a successive power of 2 and adding the results from least to most significant bit. The document also gives examples of using Horner's rule to convert ternary and hexadecimal numbers to decimal.

Uploaded by

Bijay Nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views4 pages

Horners Convert

The document explains Horner's rule, which is an efficient algorithm for converting numbers between different number bases, such as binary to decimal. It provides examples of using Horner's rule to convert several binary numbers to decimal by multiplying each bit by a successive power of 2 and adding the results from least to most significant bit. The document also gives examples of using Horner's rule to convert ternary and hexadecimal numbers to decimal.

Uploaded by

Bijay Nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Horner’s Rule

Horner’s rule is an efficient algorithm for converting a number


written in base b into its decimal notation.
Horner’s rule is also useful for evaluating a polynomial, and Taylor
coefficients.
Evaluating polynomials by Horner’s rule is covered elsewhere in
this course.

Horner’s Rule
Consider the natural number 43. Writing 43 as a sum of powers
of 2 implies its binary representation.

43 = 32 + 8 + 2 + 1

43 = 1 · 25 + 0 · 24 + 1 · 23 + 0 · 22 + 1 · 21 + 1 · 20
43 = (10 1011)2
Horner’s rule writes converts (10 1011)2 to 43 from the most sig-
nificant bit to the least significant bit.

43 = (((((1 · 2) + 0) · 2 + 1) · 2 + 0) · 2 + 1)

This multiplicity of parentheses is somewhat confusing, so let’s re-


formulate it.

Horner’s Rule to Convert Binary to Decimal


To convert (10 1011)2 to decimal:
1. write the bit pattern to be converted (leave sufficient space
between bits)
1 0 1 0 1 1

2. Next, bring down the leading 1

1 0 1 0 1 1

(Continued next slide)

1
Example Continued

Continuing from the previous slide.


3. Multiply the 1 by 2 and place it under the next bit.

1 0 1 0 1 1
2
1

4. Add the values in the second column.

1 0 1 0 1 1
2
1 2

5. Repeat the process.

Example Continued

Continuing from the previous slides.

Multiply 2 by 2 and add 1.

1 0 1 0 1 1
2 4
1 2 5

Multiply 5 by 2 and add 0.

1 0 1 0 1 1
2 4 10
1 2 5 10

2
Example Continued

Continuing from the previous slides.

Multiply 10 by 2 and add to 1.

1 0 1 0 1 1
2 4 10 20
1 2 5 10 21

Multiply 21 by 2 and add 1.

1 0 1 0 1 1
2 4 10 20 42
1 2 5 10 21 43

Therefore, (10 1011)2 = 43.

Other Examples of Binary to Decimal Conversion

Here’s an example computation of Horner’s rule to convert bi-


nary (1101 0100)2 to decimal 212.

Horner’s Rule
1 1 0 1 0 1 0 0
2 6 12 26 52 106 212
1 3 6 13 26 53 106 212

And here is a second example.

Horner’s Rule
1 0 0 0 1 1 1 1
2 4 8 16 34 70 142
1 2 4 8 17 35 71 143

Therefore, (1000 1111)2 = 143.

3
Converting Ternary to Decimal

You can also use Horner’s rule convert from bases other than 2
to decimal.

Here’s an example computation of Horner’s rule to convert


ternary (210)3 to decimal 21.

Horner’s Rule base=3


2 1 0
6 21
2 7 21

Converting Hexadecimal to Decimal

Here’s an example computation of Horner’s rule to convert hex-


adecimal (CAFE)16 to decimal 51966.

Horner’s Rule base=16


C A F E
192 3232 51952
12 202 3247 51966

Because ( DEAD CODE)16 is an interesting string you might want


to convert it to decimal.

You might also like