Converting from Oct. to Dec. and Dec. to Oct.

Started by Ayzìsìt Alenantang, February 11, 2010, 02:55:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ayzìsìt Alenantang

Kaltxì, ma smukan sì smuke!
As we all know, the Na'vi number system eas released recently, using the base of 8 (octal system).
I would like to present two converting ways to Dec. (base 10).

dec -> oct

When we want to convert a number to use in Na'vi, we need to find out what is it equal to in Octal base.
The formula is dividing the number by eight, and write the remnant (what remains- 9/8=1 and the remnant is 1. if it's the wrong word, let me know) on the side.
Next, we divide the result from the previous dividing (NOT the remnant) and divide it by 8, writing the remnant on the LEFT of the previous one. We repeat this proscess until the result of the division by 8 is 0.

For example:
71/8=8 (remnant 7)
8/8=1 (remnant 0)
1/8=0 (remnant 1)

Remnants:
107

Meaning that 71(dec)=107(oct).
Fractions are added using 1/2 to represent a half, and NOT 0.5.

Oct-> dec

This one is more complicated. First, we need to understend how to analyze a number (in the base of 10):

134= 1*100+3*10+4*1 (* is multiplication)
134= 1*10^2+3*10^1+4*10^0

In the base of eight, we do the same thing, but with 8. For example:

134(oct)= 1*8^2+3*8^1+4*8^0
134=64+24+4
134=92

Meaning that Octal 134 is equal to Dec. 92.
Note that fractions are done with a negetive power:

107.4(oct)=1*8^2+0*8^1+7*8^1+4*8^(-1)
107.4=64+24+0.5
107.4(oct)=71.5

Notes:
*A negetive number remains negetive
*This could be also applied to different bses, I used octal specifically for Na'vi.
*If you want to do mathematival actions in octal
base, you can always convert to decmal, do the math, and then back to octal.

I hope this helps you out, because you won't always have a calculator of different bases.
Kìyevame ulte Eywa ngahu, oeyä ayeylan.
"Tìfnu! Oel ngati tspang!"
"Silance! I kill you!"
~Achmed, the dead terrorist.

eanayo

#1
Ah, good stuff you have there :)

Just as an addendum:
For converting decimal to octal, some people may find repeated subtraction (well, actually division and subtraction) easier to do in mind than full integer division with remainder.

Another (equivalent) way is:
Find the largest 8k that still fits in your decimal number, then, for n=k..0, integer divide your decimal number by 8n (result r), subtract r*8n from you number and repeat. The r's form your octal number (MS digit first)

For your example (7110 to octal):
71 -> 82=64 is largest power of 8 that fits.
71 / 64 = 1
 71-1*64 = 7
7 / 8 = 0
 7-0*8 = 7
7 / 1 = 7


so 7110 = 1078

Of course, this is mathematically equivalent to what you said, but it avoids the "long" integer divisions (71/8 AND 71%8 is nasty to do without pen and paper, at least for me ;) ) YMMV, though.

*ponders whether or not to do an 'Na'vi numbers and the octal system' worksheet*

Visit Our Dictionary for eBook readers, The Na'vi Word Puzzle Game and the Cryptogram Generator
srake tsun pivlltxe san [ˈɔaχkat͡slʃwɔaf]?