• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

Base conversions: Math help, please.

Sage Noctowl

Because Awesome-me = 2 times the awesome
Okay, well, I've been working on a base-converting project, and I've figured out the easy conversions (How to Convert Octal to Quaternary, as shown in the attachment), but I seem to be stuck. According to the direction I'm going, to convert from binary to decimal, I have to group the numbers into groups of 1/log(2), which just isn't happening. There has to be some way to do it, and I was wondering if your brilliant minds could help me.
Thanks in advanced.
 

Attachments

  • Simple Base conversions.txt
    2.7 KB · Views: 4
Um, just add together the powers of two corresponding to the placement of the ones in the binary representation?

100101 = 2^5 + 2^2 + 2^0 = 32 + 4 + 1 = 37.
 
Yeah, that's the way I thought, but what happens when you have a harder problem that you can't do manually? For example, trying to convert from octal to a base 7 system, with 20 digits? Again, I can't group in terms of "log (7)/log (8)", because it would create an irrational fraction.
 
logs 2/10 is irrational, too. try to stop complicating things for yourself. this kind of stuff requires the proper mindset to approach.
 
How worried about performance are you? a simple, though probably not fastest flop-wise, way to convert between the two bases would be to recursively divide the number by the second base, and record the remainders as your new number.

for instance, converting decimal to binary:
168273
quotient | remander
84136 | 1
42068 | 0
21034 | 0
10517 | 0
5258 | 1
2629 | 0
1314 | 1
657 | 0
328 | 1
164 | 0
82 | 0
41 | 0
20 | 1
10 | 0
5 | 0
2 | 1
1 | 0
0 | 1

Collecting the remainders from last (left) to first (right), we have 101001000101010001, so 168273 in base 10 = 101001000101010001 in base 2. Would that help?
 
Back
Top Bottom