Re: TI85 Concatenating numbers/Numbers -> Strng


[Prev][Next][Index][Thread]

Re: TI85 Concatenating numbers/Numbers -> Strng



On Fri, 8 Nov 1996, Adam Wright wrote:


> Hi!
>
> I'm writing a program on my calculator and I'm trying to figure out
> how I can print something like "The answer is 33"  I know that I can
> use "+" like:
>
> "thirty-three"->answer
> Disp "The answer is "+answer
>
> and get out
> "The answer is thirty-three,"
>
> but I can't say:
> 3*11->answer
> Disp "The answer is "+answer
>
> and get out
> "The answer is 33"
>
> If I could either get the number into a string, or display the text
> and the variable, that would be great.  Thanks in advance!


You need to write a num2str routine.  Its truly a pain to do.  It involves
extracting one digit at a time by way of a multiplication modulo one order
of magnitude. (2 if binary, 8 if octal, 10 if dec, 16 if hex) Then do a
lookup to get a string equivalent and append it onto your answer.


f(x) -> x      /* f(x) is whatever you do to get x....*/
while (x>1)    /* ready to extract 1st digit*/
    x/10 -> x
    end
if (x<0):then
    answer+" -" -> answer
    -x -> x
    end
while(x>0)     /* number 0<=x<1  x10  int(ans) -> answer
    10 x -> x
    int(x) -> y
    if == 1:answer+"1" -> answer
    if == 2:answer+"2" -> answer
    if == 3:answer+"3" -> answer
    if == 4:answer+"4" -> answer
    if == 5:answer+"5" -> answer
    if == 6:answer+"6" -> answer
    if == 7:answer+"7" -> answer
    if == 8:answer+"8" -> answer
    if == 9:answer+"9" -> answer
    if == 0:answer+"0" -> answer
    x-y -> x
    end


That's kinda how I did it the last time, and I wrote a Str2Num routine
too.  I can't guarantee the above code works, cuz I'm typing it from a 6
month old memory. But you get the idea. Ask if it 's unclear...


<pre>
--
Chris Kuethe <ckuethe@gpu.srv.ualberta.ca> LPGV Electronics and Controls


RSA in 3 lines of PERL:
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
</pre>


References: