Hello, I was bored.
Code:
ClrList L1
Menu("","BIN TO DEC",B,"DEC TO BIN",D
Lbl BD
0->D
Input "",Str0
Length(Str0->L
For(A,1,L
If expr(sub(Str0,A,1
D+2^^(L-A)->D
End
Disp Ans
Stop
Lbl D
Prompt D
logBASE(D,2)->L
iPart(Ans)+(fPart(Ans)>0->L
Ans->dim(L1
For(A,L,1,-1
(10fPart(D/2)>0->L1(A
iPart(D/2->D
End
Disp L1
Could someone make this even shorter please?
Code:
ClrList L1
Menu("","BIN TO DEC",B,"DEC TO BIN",D
Lbl BD
DelVar DInput "",Str0
Length(Str0->L
For(A,1,L
If expr(sub(Str0,A,1
D+2^^(L-A->D
End
Disp Ans
Stop
Lbl D
Prompt D
logBASE(D,2
iPart(Ans)+(0<fPart(Ans->L
Ans->dim(L1
For(A,L,1,-1
0<10fPart(D/2->L1(A
iPart(D/2->D
End
Disp L1
Taking a lot of easy potshots here.
Code: Menu("","BIN TO DEC",B,"DEC TO BIN",D
Lbl B
Input "",Str0
length(Str0
Disp sum(seq(expr(sub(Str0,A,1))2^^(Ans-A),A,1,Ans
Stop
Lbl D
Prompt D
iPart(round(logBASE(D,2),8
Disp 2fPart(.5iPart(round(seq(D2^^(A-Ans),A,0,Ans),8
seq( is very powerful.
kg583 wrote:
Code: Menu("","BIN TO DEC",B,"DEC TO BIN",D
Lbl B
Input "",Str0
length(Str0
Disp sum(seq(expr(sub(Str0,A,1))2^^(Ans-A),A,1,Ans
Stop
Lbl D
Prompt D
iPart(round(logBASE(D,2),8
Disp 2fPart(.5iPart(round(seq(D2^^(A-Ans),A,0,Ans),8
seq( is very powerful.
Hmm, I've never thought of this before. It surprises me how useful some functions are . I usually only pay attention to what they are soley used for, I'm not always that creative.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum