I am trying to make a base 10 to binary converter that doesn't take up an extremely large amount of RAM. I have continuously been failing, and wondered if anyone had any ideas.

I have actually done this!

What I did was this: you use repeat loops to start doubling the value of a variable (initially set to one) so that it stops doubling the value once it is greater than the initial input number. Once the variable is greater than the initial input, it divides that variable by two and stores it to a list. It then resets the variable that was being doubled back to one and does this again (via the repeat loop). It will stop doing this once it gets to the exact number. Then it takes the list and eherever ther is a value greater than 0, it puts a one in there. I don't think I have to explain how to show the ouptut (correct me if I am wrong). Here is a pseudo code

Input Variable1

Setup list1

Repeat Sum(list1) = Variable1

1 -> Variable2

Repeat until Variable2 > Variable1

Variable2 * 2 -> Variable2

EndLoop

Variable2 -> list1(dimensionlist1 + 1)

EndLoop

Sorry about the pseudocode as opposed to TI-BASIC

I have my Base 10 to binary converted grouped and don't remember all the little mechanics of it, so I basically gave you a wrough sketch of the code since my explanation seemed a bit inadequate.

—Wolfgang

Here is a way to convert a number in N (base 10) to base B (2 to 36):

```
Input "NUMBER:",N
Input "BASE:",B
"0→Str1
While N
sub("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",1+round(BfPart(N/B),0),1)+Str1→Str1
iPart(N/B→N
End
Str1
If Ans≠"0
sub(Ans,1,length(Ans)-1
Disp Ans
```

For specifically binary:

```
Input "NUMBER:",N
"0→Str1
While N
sub("01",1+BfPart(.5N),1)+Str1→Str1
iPart(.5N→N
End
Str1
If Ans≠"0
sub(Ans,1,length(Ans)-1
Disp Ans
```

47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2

Oh. That's much better than mine. I have a really simple binary to base 10 converted sort of like this, but my base 10 to binary is no where near as good as this. Time to scrap that clunker!

—Wolfgang

Is there a code for decimals? The only thing I've thought of is:

If inString(Str1,".

shorten Str1 so it includes the stuff before the decimal, and store the rest into C

Go though that process

If C=#

take C and find C*BASE, convert that number to Str1, go through that process with it again, then output the original answer, a ".", and the new answer.

It's rather long, and it doesn't work for repeating decimals, is there any other way?

I didn't realize that decimals were ever expressed in Binary.

—Wolfgang

Well, from what I understand of decimals in other bases (even though dec means base 10), you take the number behind the decimal place and divide by the base to the power of the number of digits behind the decimal.

For example:

0.1713_{10} is 1713_{10}/(10^4) = 1713/10000, which is 0.713

This can work for other bases:

0.1011_{2} is 1011_{2}/(2^4)=11/16

Now the tricky part is repeating decimals.

(1/3)_{10} doesn't work because it can't be expressed as X/(10^Y).

So you express it in the ratio X/((10^Y)-1), which is 9, 99, 999, etc. in base 10.

The number of digits in the denominator it the length of the repeating part.

1/3 = 3/9, and 9 is 1 digit long, so it is 0.333333

But in 1/99, 99 is 2 digits long, so it is .01010101 repeating

This works in all other bases.

Take (1/5)_{2}

That's 1/101, and it can't be expressed as X/(2^Y), so it is repeating.

(2^X)-1 is 1, 11, 111, 1111 etc.

(1/101)_{2}=(11/1111)_{2} Since 1111 (the denominator) has 4 digits, it it is 4 long.

1/5=1/101=0.001100110011001100110011 repeating.

That's a lot of digits, so it's pretty accurate. Let's plug it in:

001100110011001100110011_{2}=3355443_{10}

It's 24 digits long, so 2^24=16777216

3355443/4194304=0.1999999881, which is close to .2

That works for any base.

I'm pretty sure that's how decimals in bases work, but don't quote me on it.

At first I completely didn't understand, but now I kind of get it. I don't understand the repeating decimals at all though.

—Wolfgang

Take 5/9,. It's decimal value is 0.55555

From x = 0.5555555555

We get 2 equations

10x = 5.555555555

x = 0.5555555555

Subtract them

10x - x = 5.555555555 − 0.555555555555

9x = 5

Divide both sides by 9

x = 5/9

Notice how you take the base^1 and subtract 1 to make it simple.

It works for 23/99=0.2323232323

100x=23.23232323 //10^2

x=0.23232323

100x-x=23

99x=23

x=23/99 //10^2-1

This same logic will work in all bases.

It's strange, though. There are math sites that explain how all this math works in base 10. But when you try to find math tricks for other bases, all there is is 'how to convert bases' There are no cool tricks listed for different bases, like BASE^X-1 is always the highest value the base allows repeated X times.

I think bases are really interesting; there should be tricks like these for them.

Agh! That is is so cool. I actually get it, but that is totally mind blowing! Thanks for explaining it to me.

—Wolfgang