# Mnx2 (minimum Or Maximum Element- Version 2) - HP 48gII Advanced User's Reference Manual

Graphing calculator.

12 `56 `˜šš
45 `1 `
9 `14 `
`
Select the VAR menu and execute MNX.
J %MNX%
Find the maximum element.
%MAX%

## MNX2 (Minimum or Maximum Element- Version 2)

Given an array on the stack, MNX2 finds the minimum or maximum element in the array. MNX2 uses a
different approach than MNX: it executes OBJ" to break the array into individual elements on the stack for
testing, rather than executing GETI to index through the array.
Techniques used in MNX2
FOR...NEXT (definite loop). The initial counter value is 1. The final counter value is nm
!
the number of elements in the array. The loop-clause contains the sort instructions.
User flag for logic control. User flag 10 defines the sort: When flag 10 is set, MNX2 finds the maximum
!
element; when flag 10 is clear, it finds the minimum element. You determine the status of flag 10 at the
beginning of the program.
Nested conditional. An IF...THEN...END conditional is nested in the FOR...NEXT loop, and determines
!
the following:
Whether to maintain the current minimum or maximum element, or make the current element the new
"
minimum or maximum.
The sense of the comparison of elements (either < or >) based on the status of flag 10.
"
Logical function. MNX2 executes XOR (exclusive OR) to test the combined state of the relative value of
!
the two elements and the status of flag 10.
Custom menu. MNX2 builds a custom menu that lets you choose whether to sort for the minimum or
!
maximum element. Key 1, labeled %MAX%, sets flag 10. Key 2, labeled %MIN%, clears flag 10.
2-18 RPL Programming Examples
Level 1
"
[[ array ]]
"
Level2
Level 1
[[ array ]]
Z
or Z
max
min
1, where nm is