|
-
Sep 24th, 2009, 04:17 PM
#1
Thread Starter
Fanatic Member
calculating between numeral systems
calculating from decimal to octal, hexadecimal or binary is easy... but the opposit way is harder, could someone tell me a way to calculate from octal to decimal?
like from decimal to octal:
lets say 11 decimal to octal
11/8 = 1 rest 0.375
1/8 = 0 rest 0.125
0.375 * 8 = 3
0.125 * 8 = 1
so result: 11 decimal is 13 in octal...
-
Sep 24th, 2009, 07:48 PM
#2
Re: calculating between numeral systems
The other way is actually the easy way.
Take a base 10 number. Index the digits by writing the number as an an-1 ... a0. This number is equal to an*10n+an-1*10n-1+...+a0*100. As an example, 457 gives us a_2 = 4, a_1 = 5, a_0 = 7, and the expression above gives 4*10^2 + 5*10 + 7 = 457.
Doing the same thing in other bases turns out to be easy. If we have the base 8 digits of a number, index them as above, and then we have
an an-1 ... a0 = an*8n+an-1*8n-1+...+a0*80
Using your example of 11 in decimal being 13 in octal, take a_1 = 1, a_0 = 3, and simply do 1*8^1 + 3*8^0 = 13. Since we're doing arithmetic in base 10, our final answer comes out as a base 10 number. If you're familiar with converting from binary to decimal, you do the same thing. In octal, the rightmost place is the "1's" digit, the next place is the "8's" digit, the next is the "64's" digit, etc. In base 10, we analogously have the "1's", "10's", and "100's" digits.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|