binary to computer number systems

raven_cloudwind18

New Member
Messages
5
Reaction score
0
Points
0
Can anyone help me with my problem my question is how is 55 in decimal converted to 67 in octal?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Why those two numerals? Smells a little like an assignment.

Note that you can perform the conversion directly without using an intermediate base. Repeatedly take the remainder and integer quotient of the number (i.e. divide the number by the base). The remainders are the digits from least to greatest significance. The quotient is the number used in the next round. Stop when the number is 0 (or stop a round early when the quotient < base, using the quotient as the most significant digit). For example, consider converting the base-10 numeral 123 (often written "123₁₀"; subscripts in numerals are used to indicate base) to its base 7 equivalent.

  1. 123 % 7 = 4, 123 / 7 = 17. The least digit is 4.
  2. 17 % 7 = 3, 17 / 7 = 2. The next digit is 3.
  3. 2 % 7 = 2, 2 / 7 = 0. The next (and final) digit is 2

The answer: 123₁₀ = 234₇.

The same process works if neither base is a familiar one. Let's convert 123₉ to base 7. First, the beginning of the multiplication table for 7 in base 9 and (for comparison) 10:
Code:
base: 9 | 10
--------+---
1*7=  7 |  7
2*7= 15 | 14
3*7= 23 | 21
4*7= 31 | 28
5*7= 38 | 35
6*7= 46 | 42

  1. A bit of long division to calculate 123₉ / 7:
    Code:
        015₉  ← The quotient
    7 ) 123₉
        12₉
       - 7
      ---
         43₉
        -38₉ = 5 * 7
        ---
          4  ← The remainder
    So 123₉ / 7 = 15₉, 123₉ % 7 = 4
  2. 15₉ / 7 = 2, 15₉ % 7 = 0
Thus 123₉ = 204₇

The reason this works becomes obvious if you examine what the process does to a numeral in the base you're converting to. The number M is represented in base b using the sum M = Σ aᵢ*bⁱ = a_n * bⁿ + ... + a₁ * b¹ + a₀ * b⁰, where the coefficients aᵢ are the digits of the numeral. Note the summation, like conversion, is representation-neutral; they work in any numeric representation. Conversion is easiest in base b[/b], for if you examine the numeral in base b, you'll see that the remainder is the least significant digit and division by b is a right shift. The general process is:

  1. M = Σ aᵢ*bⁱ = a_n * bⁿ + ... + a₁ * b¹ + a₀ * b⁰
  2. M₁ = Σ aᵢ*bⁱ⁻¹ = a_n * bⁿ⁻¹ + ... + a₂ * b¹ + a₁ * b⁰; next digit: a₀
  3. M₂ = Σ aᵢ*bⁱ⁻² = a_n * bⁿ⁻² + ... + a₃ * b¹ + a₂ * b⁰; next digit: a₁
  4. ...

(Note: I use "_n" for a subscripted "n" because the Unicode "subscript n" character, ₙ, isn't recognized on any computer I tested; it's not in any font, and it's not even listed in the system character viewers.)

Or, using base b numerals:
  1. Start: M = a_n ... a₃ a₂ a₁ a₀
  2. M₁ = a_n ... a₃ a₂ a₁; next digit: a₀
  3. M₂ = a_n ... a₃ a₂ ; next digit: a₁
  4. ...

Isn't working with different bases easy?

See also the many questions about bases from Ask Dr. Math.
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Life would be so much easier if every forum integrated LaTeX into their markup/markdown, like they do at the math and physics StackExchange sites. Time to do some investigating...
 

Darkmere

New Member
Messages
358
Reaction score
2
Points
0
Mission isnt Octal Base 8 rather than Base 7? From what I learned Septenary is Base 7 and Octal is Base 8
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Darkmere -- misson's example was about computing a representation of a number in any arbitrary base, and he specifically said that the first example was to convert to base 7. (The introductory paragraph can be roughly translated as, "I'm not going to do your homework for you.") The point was to give the general method, not the solution to a specific problem. Teaching a man to fish, so to speak, rather than throwing a halibut his way.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Give a man a fire and he's warm for the day. But set fire to him and he's warm for the rest of his life

Life would be so much easier if every forum integrated LaTeX into their markup/markdown, like they do at the math and physics StackExchange sites.
Heck, I'd settle for <sub> and <sup>
 

Darkmere

New Member
Messages
358
Reaction score
2
Points
0
Yeah I was surprised that the [sub] and [sup] bb code doesn't work either
 

adam.k

New Member
Messages
41
Reaction score
1
Points
0
Just on the topic of Octal and Decimal, a joke I heard courtesy of my computer science professor
"Real programmers always confuse Halloween and Christmas because Oct31 == Dec25" - Andrew Rutherford

This made so much more sense after reading these posts about converting decimal to octal

Thanks for making me laugh!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The great thing about understanding numeric bases is polynomial arithmetic becomes a breeze. What's "3x²+4x¹+2x⁰" but a simpler (no restriction on coefficients and no carries in addition) numeral in an indeterminate base? Then, with a little modular arithmetic as a stepping stone to explaining quotient groups (and quotient rings), you can derive complex numbers, essentially defining them into existence.

BAM! In 20 minutes, you've done junior-level math.
 
Last edited:
Top