--- title: "cmp (Compare)" slug: "calc-function-cmp" updated: 2026-05-12T12:12:43Z published: 2026-05-12T12:12:43Z canonical: "docs.lobstersoftware.com/calc-function-cmp" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # cmp (Compare) > [!NOTE] > The function $cmp compares two values with each other and returns a truth value as result. A compare operator specifies how the values are compared with each other. > > > [!TIP] > > Tooltip > > > > Syntax: *$cmp(left,operator,right[,mode])* > > > > | Parameter | Description | > > | --- | --- | > > | `left` | The left compare value. | > > | `operator` | Defines the compare operator. The following operators are available: - = or == (equals) - != (unequal to) - < (less than) - <= (less than or equal) - > (greater than) - >= (greater than or equal) - reg (regular expression) | > > | `right` | The right compare value. | > > | `mode` | An optional compare mode that specifies whether the comparison should be numeric or text-based. The following modes are available: - i (integer) - n (numeric) - s (text based) → default, if nothing is specified - o (object based) → e.g. if two date values are to be compared | > > > > Returns *true* if the condition for the comparison "left operator right" is fulfilled, otherwise *false*. > > > > Example: $cmp(10,>,5) – Returns true, because 10 is greater than 5 ## Syntax *$cmp(left,operator,right[,mode])* ## Parameter | Name | Description | | --- | --- | | left | The left comparison value. | | operator | Defines the compare operator. The following operators are available: - = or == (equals) - != (unequal to) - < (less than) - <= (less than or equal) - > (greater than) - >= (greater than or equal) - reg (regular expression) | | right | The right comparison value. | | mode | An optional compare mode that specifies whether the comparison should be numeric or text-based. The following modes are available: - i (integer) - n (numeric) - s (text based) → default, if nothing is specified - o (object based) → e.g. if two date values are to be compared | ## Return value Returns *true* if the condition for the comparison "left operator right" is fulfilled, otherwise *false*. ## Example | Syntax | Result | Remarks | | --- | --- | --- | | $cmp(2,>,11,n) | false | The number "2" is not greater than the number "11". | | $cmp(2,>,11,s) | true | In a text-based comparison, "2" is greater than "11" because the ASCII character code of "2" is greater than that of "1". | | $cmp(2,>,11) | true | Same reason as above. **s** is the default mode. | | $cmp(0,==,0) | true | | | $cmp(Hallo,==,Hallo) | true | | | $cmp(hallo,==,Hallo) | false | Case sensitive. | | $cmp(Hallo,reg,/^hallo$/i) | true | Regular case insensitive comparison. |