NAME
    cmp - compare two values

SYNOPSIS
    cmp(x, y)

TYPES
    x		real, complex, string, object (calls xx_cmp)
    y		real of complex (if x is real or complex)
		same as x (if x is string or object)

    return	int

DESCRIPTION
    Compare two values and return -1 if x < y, 0 if x == y or 1 if x > y.
    Comparison by type is indicated below.  Where more than one test is
    indicated, tests are performed in the order listed.  If the test is
    inconclusive, the next test is performed.  If all tests are
    inconclusive, the values are considered equivalent.

    real
	the greater number is greater

    complex
	greater absolute values are greater
	greater arguments (angles) are greater

    string
	the string with the greater dissimilar character is greater
	the longer string is greater

    object
	the greater object as defined by xx_cmp is greater

    String comparison is performed via the strcmp() libc function.

    Note that this function is not a substitution for equality.  The ==
    operator always takes epsilon() into account when comparing numeric
    values.  For example:

	> cmp(1, 1+epsilon()/2)
		-1
	> 1 == 1+epsilon()/2
		0

    It should be noted epsilon() is used when comparing complex values.

EXAMPLE
    > print cmp(3,4), cmp(4,3), cmp(4,4), cmp("a","b"), cmp("abcd","abc")
    -1 1 0 -1 1

    > print cmp(3,4i), cmp(4,4i), cmp(5,4i), cmp(-5,4i), cmp(-4i,5), cmp(-4i,-5)
    -1 -1 1 1 -1 -1

    > print cmp(3i,4i), cmp(4i,4i), cmp(5i,4i), cmp(3+4i,5), cmp(3+4i,-5)
    -1 0 1 1 -1

    > print cmp(3+4i,3+4i), cmp(3+4i,3-4i), cmp(3+4i,2+3i), cmp(3+4i,-4-5i)
    0 1 1 -1

LIMITS
     none

LIBRARY
    BOOL comparevalue(VALUE *y, *y)	(any, return TRUE if they differ)
    FLAG relvalue(VALUE *x, *y)		(real, string, object, return -1,0 or 1)

SEE ALSO
    abs, epsilon
