TIB: Re: Displaying a sequence
[Prev][Next][Index][Thread]
TIB: Re: Displaying a sequence
Alright, here is one area of 86 basic that I
have thoroughly explored. If you want to display numbers and strings
together on one line, you are probably going to use the Outpt( command.
The problem then becomes properly spacing the numbers--things which may require
varying space. The solution is to mathematically compute how much space
each one requires. Before your program attempts to write the
"sequence" to the screen, place this line of code:
y=iPart log abs (x+(x==0))+(sign x==-1)
Then when you want to know how many *extra*
spaces a number requires, store the variable containing the number into
x:
:B->x
And then y will contain the number of *extra*
spaces (more than 1) the number requires. I won't go into details about
how I came up with this and how it really works, since all you need to know is
how to work it. This algorithm will make y become 1 if x is for instance
43. It will make y 2 if x= -10. Remember, it only tells how many
extra digits beyond 1 a number requires. In addition, if you're dealing
with several numbers, don't forget to store those extra digits
somewhere.
For example, if you need to display
"(X+A)^2+(Y+B)^2=C", (the standard equation for a circle) where A, B,
and C are some integer:
(keep in mind "^2" is one char and "->"
means store)
:y=iPart log abs (x+(x==0))+(sign
x==-1)
:Disp "Equation of a
Circle:"
:Disp
"(X+",""
:Outpt(2,4,A
:A->x
:Outpt(2,5+y,")^2+(Y+"
:Outpt(2,11+y,B
:y->D
:B->x
:Outpt(2,12+D+y,")^2="
:Outpt(2,15+D+y,C
:Disp
-A>Frac
:Outpt(4,1,"H="
:Disp
-B>Frac
:Outpt(5,1,"K="
:Disp
(sqrt)C>Frac
:Outpt(6,1,"R="
Notice how I stored the first "y"
value to "D", then later added "D" to the new "y"
value. Don't forget that with equation variables such as "y",
the variable only gets evaluated when you use it. So you can change the
value of "x" and "y" will give you different answers.
I also displayed the A,B,and C values below the "sequence" line just
in case there were decimal places in the numbers (which will screw it up in this
case), that you could still know what those values were, in fractional
format.
Now if your number might have decimal places, you need to put
in some extra IF-THEN statements saying: IF "iPart" of the number does
not equal the number, THEN set the mode to Fixed 3 or something and make space
for 4 more characters (remember the decimal point!)
Hope this helps!
~Dave <the_regul8r@bigfoot.com>
Hi, does anyone know how I could display a
"sequence" such as the following,
in a continuous line?
If I try to display the "sequence", my calculator
(86) displays
each item on a new line.
Here is what I am trying to
Display:
:Disp
A,"X",A(-Q),"=",B,"Y",B(-R)
If A is 1,
B is 2, Q is 3, and R is 4, then this is what I would like it to
display
in a single line, reading left to right (memory is not a
concern):
1 X -3 = 2 Y -8
Any help would be greatly
appreciated
Ryan