HP 48gII Advanced User's Reference Manual page 42

Graphing calculator
Hide thumbs Also See for 48gII:
Table of Contents

Advertisement

«  x 'IFTE(x‹0,SIN(x)/x,1)' »
Example:
Two Conditional Actions. This program multiplies two numbers together if they're both
nonzero — otherwise, it returns the string "ZERO".
Program:
«
 n1 n2
«
IF
'n1‹0 AND n2‹0'
THEN
n1 n2 *
ELSE
"ZERO"
END
»
»
Example:
Two Conditional Actions. This program tests if two numbers on the stack have the same value.
If so, it drops one of the numbers and stores the other in variable V1 — otherwise, it stores the number from
level 1 in V1 and the number from level 2 in V2.
Program:
«
IF
DUP2
SAME
THEN
DROP
'V1' STO
ELSE
'V1' STO
'V2' STO
END
»
`
OTST K
Enter the numbers 26 and 52, then execute TST to compare their values. Because the two numbers aren't equal,
the VAR menu now contains two new variables V1 and V2.
26 `52 J %TST%
Example:
Multiple Conditional Actions. The following program stores the level 1 argument in a variable
if the argument is a string, list, or program.
1-16 RPL Programming
Comments:
Creates the local variables.
Starts the defining procedure.
Starts the test clause.
Tests n1 and n2.
If both numbers are nonzero, multiplies the two values.
Otherwise,
returns the string ZERO.
Ends the conditional.
Ends the defining procedure.
Comments:
For the test clause, copies the numbers in levels 1 and
2 and tests if they have the same value.
For the true clause, drops one of the numbers and
stores the other in V1.
For the false clause, stores the level 1 number in V1
and the level 2 number in V2.
Ends the conditional structure.
Puts the program on the stack. Stores it in TST.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

49g+

Table of Contents