Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started 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
int(round(BfPart(NB^seq(I,I,‾int(ln(N)/ln(B))-1,‾1
However, typing it into the homescreen returns an Err:Argument.
-
Compatible all bases.
-
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
" →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.
-
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.
-
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.
-
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 ;)
-
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
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)?
-
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.
-
Can you make a screenie? :-\ It works for me...
Maybe you make some obscure typo?
-
It's working in Wabbit, but not on my calc itself.
EDIT: A RAM clear fixes it ???
-
Ooh...
Testing any glitchy programs recently? :D
EDIT: Versailles.
-
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.