Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: AngelFish on November 10, 2010, 05:50:45 pm

Title: Decimal Binary conversion
Post by: AngelFish on November 10, 2010, 05:50:45 pm
Does anyone know of an efficient way to convert decimal numbers and store each digit of the output to a separate place?

I'm aware of Weregoose's

Code: [Select]
int(round(BfPart(NB^seq(I,I,‾int(ln(N)/ln(B))-1,‾1

However, typing it into the homescreen returns an Err:Argument.
Title: Re: Decimal Binary conversion
Post by: kindermoumoute on November 10, 2010, 06:25:25 pm
Compatible all bases.

Title: Re: Decimal Binary conversion
Post by: meishe91 on November 10, 2010, 06:35:34 pm
Here's the method I wrote to turn decimal to binary quite a while ago. Not sure what I could come up with now though, just to lazy :P

Code: [Select]
" →Str3
Prompt A
While A≥1
iPart(A)/2→A
Str3+sub("10",1+not(fPart(Ans)),1→Str3
End
For(X,1,length(Ans)-1
sub(Ans,2X,1)+Ans
End
sub(Ans,1,X

Should work.

What do you mean though by store each digit in a separate place?

The thing about Weregoose's is that it exports into a list (and I don't remember correctly or not but it might still be reversed too) and lists can be tricky to manipulate.
Title: Re: Decimal Binary conversion
Post by: AngelFish on November 10, 2010, 07:26:11 pm

What do you mean though by store each digit in a separate place?

The thing about Weregoose's is that it exports into a list (and I don't remember correctly or not but it might still be reversed too) and lists can be tricky to manipulate.

Well, I kind of want it in lists. I need to deal with the individual digits separately and they're going to be exported into a string in a particular order. That means that I'd eventually have to store to lists anyway. Plus, lists make it easy to pad the output, so I can have the fixed list size that I need.
Title: Re: Decimal Binary conversion
Post by: meishe91 on November 10, 2010, 07:49:14 pm
Well what kind of manipulating are you looking at doing? Like specifically. Are you trying to put all the ones at the beginning, at the end, randomize it all just with a set number of each, etc.
Title: Re: Decimal Binary conversion
Post by: AngelFish on November 10, 2010, 07:53:40 pm
I'm playing with the formatting of the Save file in Battlefield. It's rather complex, involving a lot of intermixed data. It's a security thing. Can't have people knowing which bits to flip to cheat the game ;)
Title: Re: Decimal Binary conversion
Post by: Deep Toaster on November 10, 2010, 07:59:28 pm
Does anyone know of an efficient way to convert decimal numbers and store each digit of the output to a separate place?

I'm aware of Weregoose's

Code: [Select]
int(round(BfPart(NB^seq(I,I,‾int(ln(N)/ln(B))-1,‾1

However, typing it into the homescreen returns an Err:Argument.

It works for me ??? And I think that's just about the most optimized base converter you can get with BASIC. Are you using the vars correctly (base (2 in this case) in B, your decimal in N)?
Title: Re: Decimal Binary conversion
Post by: AngelFish on November 10, 2010, 08:00:49 pm
Yep. I checked the variables. However, without changing the variables, splitting it up eliminates the error.

 ???

The program is working now. Thanks for the help.
Title: Re: Decimal Binary conversion
Post by: Deep Toaster on November 10, 2010, 08:04:08 pm
Can you make a screenie? :-\ It works for me...

Maybe you make some obscure typo?
Title: Re: Decimal Binary conversion
Post by: AngelFish on November 10, 2010, 08:12:14 pm
It's working in Wabbit, but not on my calc itself.

EDIT:  A RAM clear fixes it  ???
Title: Re: Decimal Binary conversion
Post by: Deep Toaster on November 10, 2010, 08:14:04 pm
Ooh...

Testing any glitchy programs recently? :D

EDIT: Versailles.
Title: Re: Decimal Binary conversion
Post by: AngelFish on November 10, 2010, 08:18:14 pm
The only Assembly program I've used in the past week is Scout David's 3D racer, excluding apps and the Axe code that I started writing after I ran into this problem.