TIB: re: Number-String conversion on 86 (FWD)


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

TIB: re: Number-String conversion on 86 (FWD)




Original message from unibomer@juno.com (Jared Ivey) to bkalafut@juno.com
(Ben Kalafut) Tue,18 Aug 1998
(I didn't feel like retyping it all so I forwarded this)

-Ben

p.s:  HTML mail looks terrible in the digest and sometimes gets to the
point where it takes up so much space that it is a nuisance.  The problem
has been becoming more prevalent.  On other lists I'm on (in the
aquarium/fishkeeping community) it is a convention (netiquette,
basically) not to do this or send anything MIME-encoded to a list.

~~~Begin Fwd~~~
>I'm looking for equivalents to the old MS-Basic (gw-basic,
>basica,quickbasic) VAL (Changes a string to a value) and
>STRING$(Changes a numerical variable to a string) commands.


I'm not replying through the list since some don't like off topic posts,
but I still feel that it's a valid programming question.


You will need to create a little program named r2s
to convert a real number to a string.

Program: r2s
:LinR {0,1},{Ans,Ans   ;perform a linear regression on a number.
:Eq>St(RegEq,q         ;# is in Regression Equation, get it out.
:sub(q,1,lngth q-3     ;the last 3 characters aren't part of the
                       ;number, and will always be "+0x" since the
                       ;equation is in the form y="b+mx".  b is
                       ;the value of your number and m will always
                       ;be 0 (constant function slope is 0).


Now you need to know how to use it within your program:

Program: yourProg
:"22"\->\S        ;your number as a string.
:St>Eq(S,T        ;convert string to Equation.
:T\->\T           ;store the value of the equation into
                  ;itself.  I don't think it's necessary
                  ;but it is when you use indexed variables
                  ;(ie: list, vector, matrix).
:sin T\->\T       ;perform operation on number.
:r2s              ;convert real# in Ans to a string.
:Ans\->\T         ;result is returned through Ans.




For sake of simplicity(or counterpart to r2s), you could also write
another program to convert a string to "real"

Program: s2r
:St>Eq(Ans,q:q         ;string value in Ans is converted to an equation
                       ;a constant in equation form is functionally
equivalent to the real data type


Let me know if this was what you wanted or if you need more help.


Sincerely,
The Unibomer

Jared Ivey
Unibomer@Juno.com
http://www.geocities.com/SiliconValley/Vista/7342/
~~~end fwd~~~

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]