Vanguard Software
Forecasting & Planning Solutions
Home Products Solutions Services Customers Partners Company
 
Applying science to business management

contents.gifindex.gifprev1.gifnext1.gif

compare

Format: compare( x, y, tolerance)

Arguments: [any] x, y Values to compare

(real) tolerance Optional maximum tolerance in numeric tests; default = 0

Returns: (int) 0 if both lists are equal, -1 if x<y, and 1 if x>y

Description: Compare compares two lists containing any type of elements and returns -1, 0, or 1 indicating whether the lists are identical. If the lists are not identical, compare returns a comparison of the first two corresponding elements that do not match.

When comparing numbers, two numbers whose real and imaginary components differ by less than tolerance are considered to be equal. This feature allows you to compare numbers with allowances for floating point rounding errors.

When making comparisons between data types, e.g., comparing a string to a number, the following hierarchy is used: null < false = zero < true = all non-zero numbers < all strings < all lists and objects < all function pointers.

Examples: compare([1,"text",3],[1,"text",3]) = 0

compare([1,2,3],[1,2,3,4]) = -1

compare([1,2,3],[1,2]) = 1

compare([1,2,3],[1,3,2]) = -1

compare(true,0.1) = 0

See Also: Equal, Greater Than, Less Than

  Demand Planning  |  Financial Forecasting
Forecasting Software  |  Strategic Planning Software  |  Decision Tree Software
Decision Support Software  |  Expert System Software  |  Online Surveys

Contact Us  |  Terms of Use  |  Privacy Policy  |  Site Map
Vanguard Software
© 2011 Vanguard Software Corporation
Print this page   Email this page to a friend