Question

So I'm reading a book on how binary bits are converted into octal numbers. When trying to explain the concept, they give this equation

N= S(...((d8)2^8+(d7)2^7+(d6)2^6)+((d5)2^5+(d4)2^4+(d3)2^3)+((d2)2^2+(d1)2^1+d0))

or

N= S(...((d8)2^2 +(d7)2+(d6))2^6 + ((d5)2^2 +(d4)2^1 + (d3))2^3 + ((d2)2^2+(d1)2^1+d0))

d represents the digit found within the bit, e.g. if the least significant bit was 1, then (d0) would be 1.

I understand all of this, but they elaborate further saying that the parenthesized expressions ((d8)2^2 +(d7)2+(d6)) are coefficients of base 8 digits, N=S((d2)8^2+(d1)*8+(d0)).

Can someone explain what they mean by the parenthesized expressions being coefficients of base8 digits?

Was it helpful?

Solution

The digits di are the binary digits of the number. We can compute the number from its binary digits like this:

    n = ∑ i 2i di = 20 d0 + 21 d1 + 22 d2 + ⋯

(This is in fact what defines “binary”, if we add the condition that the digits are integers and 0 ≤ di < 2 for all i.)

Suppose we name the octal digits of the number oj. We can compute the number from its octal digits like this:

    n = ∑ j 8j oj = 80 o0 + 81 o1 + 82 o2 + ⋯

(This is what defines “octal”, if we add the condition that the digits are integers and 0 ≤ oj < 8 for all j.)

Now let's look back at the binary equation. The first step is the trickiest. We will change the way the subscript is used so that each term of the summation uses three binary digits:

    n = ∑ j 23 j + 0 d3 j + 0 + 23 j + 1 d3 j + 1 + 23 j + 2 d3 j + 2

Convince yourself that that equation computes the same n as the first equation I gave.

I assume you know that xa + b = xa xb. So we can separate those 23 j + b coefficients like this:

    n = ∑ j (23 j 20) d3 j + 0 + (23 j 21) d3 j + 1 + (23 j 22) d3 j + 2

Then we can factor out the 23 j term like this:

    n = ∑ j 23 j (20 d3 j + 0 + 21 d3 j + 1 + 22 d3 j + 2)

I assume you also know that xa b = (xa)b. So we can split the 23 j term like this:

    n = ∑ j (23)j (20 d3 j + 0 + 21 d3 j + 1 + 22 d3 j + 2)

And we can simplify 23 to 8:

    n = ∑ j 8j (20 d3 j + 0 + 21 d3 j + 1 + 22 d3 j + 2)

Compare this to the formula for computing the number from its octal digits, which I repeat here:

    n = ∑ j 8j oj

So we can conclude this:

    oj = 20 d3 j + 0 + 21 d3 j + 1 + 22 d3 j + 2

For example, let's take j = 2:

    o2 = 20 d3×2 + 0 + 21 d3×2 + 1 + 22 d3×2 + 2 = 20 d6 + 21 d7 + 22 d8

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top