Compare Number
Summary
- Internal name:
CompareNumber - Category: Tools
- Purpose: Compare two numeric values using a configurable comparison operator and return a boolean result.
- Task type: Conditional
Compatibility
-
Minimum AndroMate version:
1.1.0 -
Maximum AndroMate version:
1.1.0 -
Minimum Android:
Android 13 (API 33) -
Maximum Android tested:
Android 16 (API 36) -
Supported manufacturers:
- ✅ Samsung (One UI 6.x / 7.x / 8.x)
- ✅ Google Pixel (Android Stock)
- ⚠️ Other manufacturers — not tested
-
Required permissions:
- None
Detailed description
The Compare Number task compares two numeric values (num_x and num_y) using a specified comparison operator. It returns true or false and routes execution to the corresponding branch in the workflow graph.
Both num_x and num_y support $workflow_variable references — they are resolved at runtime and parsed as double values before the comparison is performed. Default value for both is 0.
Comparison operators
The compare_type field is an integer code that determines how num_x is compared against num_y.
compare_type code |
Operator | Condition |
|---|---|---|
1 |
== |
num_x is equal to num_y |
2 |
> |
num_x is strictly greater than num_y |
3 |
< |
num_x is strictly less than num_y |
4 |
>= |
num_x is greater than or equal to num_y |
5 |
<= |
num_x is less than or equal to num_y |
Input parameters
| Parameter | Type | Required | Possible values | Android Compatibility | AndroMate Compatibility | Default |
|---|---|---|---|---|---|---|
num_x |
Double | Yes | Any numeric value — supports $variable references |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | 0 |
num_y |
Double | Yes | Any numeric value — supports $variable references |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | 0 |
compare_type |
Integer | Yes | 1 (==) / 2 (>) / 3 (<) / 4 (>=) / 5 (<=) |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | — |
Output parameters
This task is a conditional task — it produces no output variables. The boolean result controls the execution branch:
| Result | Condition | Branch taken |
|---|---|---|
true |
Comparison condition is satisfied | "true" link |
false |
Comparison condition is not satisfied | "false" link |
Exceptions
| Code | Exception Name | Description |
|---|---|---|
COMPARE-VAR-001 |
Unsupported Compare Type | The value provided in compare_type does not match any supported operator code. Accepted codes: 1 (==), 2 (>), 3 (<), 4 (>=), 5 (<=). |
Execution flowchart
The following diagram illustrates the actual implementation based on the Android code:
flowchart TD
Start([Start CompareNumber]) --> ReadType[📋 Read compare_type integer code]
ReadType --> ValidateType{Known code?}
ValidateType -->|No| E1[❌ COMPARE-VAR-001]
ValidateType -->|Yes| ResolveX[🔄 Resolve num_x\nfrom workflow context]
ResolveX --> ResolveY[🔄 Resolve num_y\nfrom workflow context]
ResolveY --> Eval{Evaluate\nnum_x OP num_y}
Eval -->|code 1 — ==| EqualOp["num_x == num_y"]
Eval -->|code 2 — >| SupOp["num_x > num_y"]
Eval -->|code 3 — <| InfOp["num_x < num_y"]
Eval -->|code 4 — >=| EqualSupOp["num_x >= num_y"]
Eval -->|code 5 — <=| EqualInfOp["num_x <= num_y"]
EqualOp --> Result{boolean result}
SupOp --> Result
InfOp --> Result
EqualSupOp --> Result
EqualInfOp --> Result
Result -->|true| True([✅ true → follow true branch])
Result -->|false| False([✅ false → follow false branch])
E1 --> Error([❌ Exception])
style Start fill:#e3f2fd
style True fill:#c8e6c9
style False fill:#ffe0e0
style Error fill:#ffcdd2
style E1 fill:#ffcdd2
style ResolveX fill:#fff9c4
style ResolveY fill:#fff9c4
style EqualOp fill:#f3e5f5
style SupOp fill:#f3e5f5
style InfOp fill:#f3e5f5
style EqualSupOp fill:#f3e5f5
style EqualInfOp fill:#f3e5f5
How it works:
- Read operator:
compare_typeinteger code is read from the task JSON - Validate: if the code is unknown, throws
COMPARE-VAR-001 - Resolve operands:
num_xandnum_yare resolved from the workflow context and parsed asdouble - Execute comparison: the corresponding numeric comparison is applied
- Return result:
trueorfalse— the workflow engine routes to the corresponding branch
Code examples
Example 1 — Equality check
{
"CompareNumber": [
{
"id": "1",
"title": "HTTP 200?",
"num_x": "$http_status",
"num_y": "200",
"compare_type": 1
}
]
}
Returns true if $http_status equals 200.
Example 2 — Less than
{
"CompareNumber": [
{
"id": "2",
"title": "RTT acceptable?",
"num_x": "$rtt_ms",
"num_y": "500",
"compare_type": 3
}
]
}
Returns true if $rtt_ms is strictly less than 500.
Example 3 — Greater than or equal
{
"CompareNumber": [
{
"id": "3",
"title": "Signal strong enough?",
"num_x": "$signal_dbm",
"num_y": "-80",
"compare_type": 4
}
]
}
Returns true if $signal_dbm is greater than or equal to -80.
Input parameter details
1. Input parameter: num_x
The left-hand numeric operand. Supports $workflow_variable references — resolved at runtime and parsed as a double before comparison.
- Default:
0 - Supports variables: Yes
2. Input parameter: num_y
The right-hand numeric operand. Supports $workflow_variable references — resolved at runtime and parsed as a double before comparison.
- Default:
0 - Supports variables: Yes
3. Input parameter: compare_type
An integer code that selects the numeric comparison to apply between num_x and num_y.
| Code | Operator | Condition |
|---|---|---|
1 |
== |
num_x equals num_y |
2 |
> |
num_x strictly greater than num_y |
3 |
< |
num_x strictly less than num_y |
4 |
>= |
num_x greater than or equal to num_y |
5 |
<= |
num_x less than or equal to num_y |
- Default: — (required, no default — triggers
COMPARE-VAR-001if unknown code)