Re: TI85 Concatenating numbers/Numbers -> Strng


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

Re: TI85 Concatenating numbers/Numbers -> Strng



OK. This is the last post on the subject, for those who are interested.
Someone e-mailed me a great trick to convert a number into a string
quickly and easily (on the 85 at least). Here's the code...
let's say you have the variable A that contains the number
-1234.56789e-34 or any other number. To put the string -1234.56789e-34
in B, just use this:


LinR {0,1},{A,A
Eq>St(RegEq,X
Sub(X,1,length X-3
Ans->B


This is  faster than my " super-fast" algorythm for everything except
one or two digit integers, plus it's hastle free and memory-friendly.
I've included the e-mail documentation  which has an explanation of how
the trick works and the names of the authors.


-Jonathan


*************************




Real-to-String/String-to-Real Modules
-------------------------------------
By Jon Niehof and Jason Wenger
------------------------------
Use these things however you wish.
Note that both routines assume that the input is in Ans and that the output
belongs in Ans. Careful--no error checking! Feel free to examine the code.


String to Real
--------------
Most of you have probably figured this out already. Simply convert the string
to an equation, then store the equation to a variable.


Real to String
--------------
This is a little more complex. It winds up destroying xStat and yStat.
It calculates a linear regression on (0,X) and (1,X) where X is the number
you want converted. Then, since the 85 returns a Regression equation (AHA!)
in the form intercept+slope*x, just convert it to a string, then you can
simply strip off everything from the plus sign on. Remember--we put in a
point (0,X), and the intercept is the point where the x-value is zero!


***NEW STUFF***
Actually, stripping from the "+" onward is more then necessary.
I've modified the program to implement the following suggestion:
<Begin quote>


Date: Sun, 06 Oct 1996 11:48:03 EDT
From: "Jason C. Wenger" <jwenger@juno.com>
X-To: jnieho38@calvin.edu
Subject: Real to String


You are to be commended.  You have found a truly graceful and FAST way of
converting real to strings.  However, you did overlook one thing.  The
regression equation is always the answer we need and "+0x", so we con
modify your program to say:


:{Ans,Ans}->Y
:{0,1}->X
:LinR X,Y
:Eq>St(RegEq,X)


Here's the new part:


:sub(X,1,lngth x-3)


All we have to do is cut off the last three numbers, which will ALWAYS be
"+0x" ! This speeds up the program considerably.  Try it.


Please, if you can find any faults in my reasoning, (especially
situations where the regression equation does not end in "+0x")  Please
tell me so.  I'd like to post this updated version in the CALC-TI
news-list (with proper credit to you, of course) but I don't want to put
it in if it has any bugs.


Thanks for the great program,
Jason "Thursday" Wenger
jwenger@juno.com
Illegitimi no carborundum


<End quote>


I included that whole thing partially for the flattery, I admit :)
Thanks a lot to Jason for the insight! A great little birthday present
(The 6th was my birthday....)


Jason also reminded me of something that I forgot to include in the original $
The real->string routine only works between -7e499 and 7e499. I think we can $




Any questions? E-mail me:
jnieho38@calvin.edu
Visit my page! www.calvin.edu/~jnieho38


References: