This article covers standard operators used in mathematical and logical expressions across various programming languages and tools. It also explains checked functions, a custom feature of IntelliSurvey.
In IntelliSurvey's software, operators work alongside functions to evaluate logical expressions and perform calculations. For example, they can compare two numbers to see if one is bigger, check if two things are the same, or combine different pieces of information.
Text comparison operators
Text (string) comparison operators can technically be used for both text and numbers. However, when used with numbers, these operators treat the numbers as text strings rather than numeric values.
Use the following operators for evaluating or comparing text (strings).
Operator | Meaning |
gt |
Greater than |
ge |
Greater than or equal to |
lt |
Less than |
le |
Less than or equal to |
eq |
Equal to |
ne |
Not equal to |
=~ |
Pattern matching; pattern found |
!~ |
Pattern matching; pattern not found |
Text strings:
- 'eq' and 'ne': These operators are used to check for equality or inequality (an exact match) of the text strings. These operators are case-sensitive.
- '=~' and '!~': The operators check for patterns in strings using regular expressions.
-
'gt', 'ge', 'lt', 'le': These operators compare values based on the lexicographical order (dictionary-like order) of characters. For example,
"apple" lt "banana"
is true because "apple" comes before "banana" alphabetically.
Numeric strings:
- Text comparison operators are often used with numeric strings in structured data contexts (e.g., ZIP codes, dates). They compare numeric strings lexicographically rather than numerically.
- Text comparison operators are not typically recommended for numeric value comparisons due to potential confusion or errors. Use the standard numeric comparison operators below instead.
Tip! Always compare similar types of data (e.g., numbers with numbers, text with text) to avoid unexpected results.
Numeric comparison operators
Numeric comparison operators are used for evaluating and comparing numerical values in programming and data analysis.
Use the following operators for evaluating numeric questions and radio questions.
Operator | Meaning |
> |
Greater than |
>= |
Greater than or equal to |
< |
Less than |
<= |
Less than or equal to |
== |
Equal to |
!= |
Not equal to |
Tip! Use the double equal sign for "equal to" when writing logic (e.g., $Q1==1
). The single equal sign is used for assignment in Perl.
Answer choice data comparisons
IntelliSurvey has custom checked functions for defining logic based on respondent answers. These functions can be used for multiple and single choice questions.
Function | Meaning |
Returns "true" if all available response options are selected. | |
Returns "true" if at least one of the specified response options are selected. |
|
Returns the number of items selected in a checkbox question. | |
Returns "true" if none of the specified response options are selected. |
Comments
0 comments
Please sign in to leave a comment.