Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Yeong on March 28, 2011, 07:32:27 pm

Title: yeongJIN_COOL's Universal base converter
Post by: Yeong on March 28, 2011, 07:32:27 pm
Well, this is TI-BASIC program, so no requirements are needed. :D
I didn't see any program like this in here, so I post it.
This nifty program lets you convert any base number to any base(2~36).
Posted screenshot also.
Title: Re: yeongJIN_COOL's Universial base converter
Post by: Munchor on March 29, 2011, 05:02:56 pm
Well, this is TI-BASIC program, so no requirements are needed. :D
I didn't see any program like this in here, so I post it.
This nifty program lets you convert any base number to any base(2~36).
Posted screenshot also.

I think Deep Thought made one like that but homescreen (like you could do maths with it, I think), but this is very good, nice job Yeong.
Title: Re: yeongJIN_COOL's Universial base converter
Post by: yunhua98 on March 29, 2011, 05:11:10 pm
Awesome.  ;)  Just a little thing, its spelled "Universal"  ;)
Title: Re: yeongJIN_COOL's Universial base converter
Post by: FinaleTI on March 29, 2011, 05:13:04 pm
Well, this is TI-BASIC program, so no requirements are needed. :D
I didn't see any program like this in here, so I post it.
This nifty program lets you convert any base number to any base(2~36).
Posted screenshot also.

I think Deep Thought made one like that but homescreen (like you could do maths with it, I think), but this is very good, nice job Yeong.
DT's only did bases 2,8,10 and 16. Though I guess bases other than 2,10 and 16 are really for fun, since those three are often the bases programmers use (though I guess some might use octal...). Still, looks great Yeong!
Title: Re: yeongJIN_COOL's Universial base converter
Post by: Munchor on March 29, 2011, 05:33:14 pm
Well, this is TI-BASIC program, so no requirements are needed. :D
I didn't see any program like this in here, so I post it.
This nifty program lets you convert any base number to any base(2~36).
Posted screenshot also.

I think Deep Thought made one like that but homescreen (like you could do maths with it, I think), but this is very good, nice job Yeong.
DT's only did bases 2,8,10 and 16. Though I guess bases other than 2,10 and 16 are really for fun, since those three are often the bases programmers use (though I guess some might use octal...). Still, looks great Yeong!

Oh yeah, universal bases, Deep's doesn't have it.
Also, Universal* :P
Title: Re: yeongJIN_COOL's Universial base converter
Post by: meishe91 on March 29, 2011, 06:49:32 pm
Nice, that's pretty cool. I got bored and went though and optimized it and shaved off 31 bytes.

Spoiler For Sorry Chrome Users:
Code: [Select]
ClrHome
Disp "yeongJIN-COOL'S","Universal","Base Converter","
Pause "Press Enter
ClrHome
Input "TYPE NUM ",Str1
Input "BASE OF NUM ",A
Input "BASE TO CONVERT ",Y
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str0
DelVar Xlength(Str1→B
For(D,1,A
If Str2=sub(Str0,D,1
D→E
End
X+(E-1)A^(C-1→X
End
"_→Str2
If not(X
"0→Str2
While X
sub(Str0,X-YiPart(X/Y)+1,1)+Str2→Str2
iPart(X/Y→X
If Ans<Y
Then
sub(Str0,Ans+1,1)+Str2→Str2
DelVar X
End
End
DelVar ADelVar BDelVar CDelVar DDelVar EDelVar XDelVar YDelVar Str0DelVar Str1Disp "RESULT",Str2

There are other optimizations that I missed I'm sure since I'm out of practice sort of. You can obviously shave off more if you take out the lowercase letters. It's a nice program though.
Title: Re: yeongJIN_COOL's Universal base converter
Post by: AngelFish on March 29, 2011, 07:09:15 pm
Awesome.  ;)  Just a little thing, its spelled "Universal"  ;)

Fixed just because multiple people have pointed it out...

Also, uprated the OP. That's a nice program. Does it handle decimals as well?
Title: Re: yeongJIN_COOL's Universal base converter
Post by: meishe91 on March 29, 2011, 07:12:15 pm
I don't think so since it's completely string oriented and there wasn't any code to hand a period.
Title: Re: yeongJIN_COOL's Universal base converter
Post by: AngelFish on March 29, 2011, 07:13:01 pm
:(
/me likes converting decimals
Title: Re: yeongJIN_COOL's Universal base converter
Post by: Ashbad on March 29, 2011, 07:13:52 pm
^-^ looks very nice, yeong :)
Title: Re: yeongJIN_COOL's Universal base converter
Post by: Yeong on March 29, 2011, 08:06:43 pm
Awesome.  ;)  Just a little thing, its spelled "Universal"  ;)

Fixed just because multiple people have pointed it out...

Also, uprated the OP. That's a nice program. Does it handle decimals as well?
Yes, Decimal works as well.
Title: Re: yeongJIN_COOL's Universal base converter
Post by: meishe91 on March 29, 2011, 08:09:37 pm
I believe he means decimal as in real numbers, not just integers.
Title: Re: yeongJIN_COOL's Universal base converter
Post by: Yeong on March 29, 2011, 08:10:49 pm
oh. It doesn't. XP
If someone tell me how to convert decimals, i can fix that....XD
Title: Re: yeongJIN_COOL's Universal base converter
Post by: AngelFish on March 29, 2011, 08:24:21 pm
It's not terribly difficult to do. For example, let's try something like 10.5
To convert this to binary, convert the 10 as normal (1010) and then we'll deal with the decimal. Now, decimals in binary are calculated like this: every nth decimal place after the period is calculated as 1/2n. Since .5 is equal to 1/21, it's equal to 0.1
Add this to the integer and you have your binary decimal 1010.1

:)
Title: Re: yeongJIN_COOL's Universal base converter
Post by: phenomist on March 29, 2011, 08:34:36 pm
Now that we're talking about base converters, here's my converter from around October 2010 or so.

Sorry for invading your thread :P

It currently has support for base 2 to 62 (with lowercase), and also has support for decimals and fractions (e.g. say you want to know 1/13 in binary).
Title: Re: yeongJIN_COOL's Universal base converter
Post by: Ashbad on March 30, 2011, 01:20:23 pm
It's not terribly difficult to do. For example, let's try something like 10.5
To convert this to binary, convert the 10 as normal (1010) and then we'll deal with the decimal. Now, decimals in binary are calculated like this: every nth decimal place after the period is calculated as 1/2n. Since .5 is equal to 1/21, it's equal to 0.1
Add this to the integer and you have your binary decimal 1010.1

:)

Damn, converting pi that way would suck... :P