Calculator Community => TI Calculators => TI-BASIC => Topic started by: Anima on August 01, 2011, 01:32:48 pm
Title: Number systems
Post by: Anima on August 01, 2011, 01:32:48 pm
I currently work at a small TI-BASIC program that converts numbers in the following several other systems: Binary -> Decimal Decimal -> Binary Hexadecimal -> decimal Decimal -> Hexadecimal
Currently I am working to convert a binary number to decimal. How to do it mathematically, I know, but I like the whole then fails to implement in TI-BASIC. Therefore I need some help from a math expert, can someone give me a little food for thought / Code snippets / or similar. to give to whom I do that? Would be very nice.
(I used Google translator, original german thread (http://ourl.ca/12325))
Title: Re: Number systems
Post by: AngelFish on August 01, 2011, 01:39:52 pm
Spoiler For The Most optimized base converter possible:
{<Base in>,<Base to be converted to>:prgmBASECONV Input Number ► Answer Code courtesy of weregoose.
Title: Re: Number systems
Post by: Anima on August 01, 2011, 01:50:03 pm
There is an error in line 9: ERR:ARGUMENT
I used your example code.
Title: Re: Number systems
Post by: Eiyeron on August 13, 2011, 07:15:09 pm
BIn to dec? HUm... I sugger you to make a system who'll decompose your decimal into a list or a variable right to left, then if the Nst number, then total += 2^N 00110100010 //left to right
I don't know how to explain, but i already made this... Let me think... int(10(float(.1num)) gives you the last number then (int(100(float.01(num))-last)/0 gives you the before-last number, and so on...
Hint: int log gives you the numbers composing your number -1. int log 1000011 = 6
If you use the strings, that would be easily: you just read the string right to left, then apply the famous Total + 2^n->Total! Excuse-me, I don't program with Ti...
a Hexadeciaml number support 4 bits (2^4 = 16), So divideyour numbers into 4 bits, then convert to Hexa.
Hexa to dec is easy, I think that don't need any help. Yes? So: Looping right form left, then convert 16^N, i think.
Title: Re: Number systems
Post by: BlakPilar on August 13, 2011, 07:49:58 pm
Nowhere near as optimized as weregoose's, but I made a program for all of the original systems you stated found here (http://www.ticalc.org/archives/files/fileinfo/441/44114.html). I'm sure the loops could be combined to do something like weregose's, but I' too lazy to do something like that on-calc at the moment.
EDIT: Fixed my incorrectedness :P
Title: Re: Number systems
Post by: AngelFish on August 13, 2011, 07:52:16 pm
Weregoose wrote that code I posted, not me :P
Sorry if that wasn't clear.
Title: Re: Number systems
Post by: BlakPilar on August 13, 2011, 07:56:54 pm