compareNum()

The system function MathLib.compareNum returns a result (-1, 0, or 1) that indicates whether the first of two numbers is less than, equal to, or greater than the second.

  MathLib.compareNum(
    numericField1 mathLibNumber in,
    numericField2 mathLibNumber in)
  returns (result mathLibTypeDependentResult)
result
Item defined as type INT or the following equivalent: type BIN with length 9 and no decimal places. This item receives one of the following values:
-1
numericField1 is less than numericField2.
0
numericField1 is equal to numericField2.
1
numericField1 is greater than numericField2.
numericField1
Any numeric or HEX item, as described in Mathematical (system words).
numericField2
Any numeric or HEX item, as described in Mathematical (system words).

Example

  myItem01 = 4
  myItem02 = 7

  result = MathLib.compareNum(myItem01,myItem02);

  // result = -1

Related reference
EGL library MathLib

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.