Conditional Loops (Gto) - HP -32S Owner's Manual

Rpn scientific calculator
Table of Contents

Advertisement

D01 LBL 0
D02 INPUT M
D03 INPUT N
004
INPUT T
005 GTO D
This routine (taken from the "Coordinate Transformations" program
on page 198 in part 4) is an example of an infinite loop. It is used to
collect the initial data prior to the coordinate transformation. After en
tering the three values, it is up to the user to manually interrupt this
loop by selecting the transformation to be performed (pressing [xeq] N
for the old-to-new system or [x|q) Ofor the new-to-old system)
Conditional Loops (GTO)
When you want to perform an operation until a certain condition is
met, but you don't know how many times the loop needs to repeat
itself, you can create a loop with a conditional test and a GTO
instruction.
For example, the following routine uses a loop to diminish a value A
by aconstant amount Buntil the resulting Ais less than or equal to B.
Program Lines:
fl01 LBL fl
A02 INPUT fl
fl03 INPUT B
501
LBL
S
502 RCL fl
503 RCL- B
504 STO fl
505 RCL B
506 x<y?
507 GTO S
508 VIEW fl
509 RTN
Description:
It is easier to recall A than to remember
where it is in the stack.
Calculates A — B.
Replaces old A with new result.
Recalls constant for comparison.
Is B < new A?
Yes: loops to repeat subtraction.
No: displays new A.
100
6: Programming Techniques

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents