Opérateur Binaire Entier
Résumé
- Nom interne :
IntegerBinaryOps - Catégorie : Arithmétique
- Objectif : Appliquer une opération arithmétique binaire sur deux valeurs entières et stocker le résultat dans une variable de workflow.
- Type de tâche : Normale
Compatibilité
-
Version AndroMate minimale :
1.1.0 -
Version AndroMate maximale :
1.1.0 -
Android minimum :
Android 13 (API 33) -
Android maximum testé :
Android 16 (API 36) -
Fabricants supportés :
- ✅ Samsung (One UI 6.x / 7.x / 8.x)
- ✅ Google Pixel (Android Stock)
- ⚠️ Autres fabricants — non testés
-
Permissions requises :
- Aucune
Description détaillée
La tâche Opérateur Binaire Entier applique une opération arithmétique entre deux opérandes entiers (var_n1 et var_n2) et écrit le résultat dans une variable de workflow (ops_output).
var_n1 et var_n2 supportent les références $variable_workflow — résolues à l'exécution et analysées comme int avant l'opération. La division (DIV) et le modulo (MOD) utilisent l'arithmétique entière (partie fractionnaire ignorée). Les deux lèvent ARITHMETIC-OPS-002 si var_n2 vaut 0.
Opérations supportées
Le champ arithmetic_ops est un code entier qui sélectionne l'opération à appliquer entre var_n1 et var_n2.
Code arithmetic_ops |
Opération | Description |
|---|---|---|
1 |
ADD | var_n1 + var_n2 |
2 |
SUB | var_n1 - var_n2 |
3 |
MUL | var_n1 × var_n2 |
4 |
DIV | var_n1 ÷ var_n2 (division entière) |
5 |
MOD | var_n1 % var_n2 (reste) |
6 |
POW | var_n1 ^ var_n2 (puissance) |
Paramètres d'entrée
| Paramètre | Type | Obligatoire | Valeurs possibles | Compatibilité Android | Compatibilité AndroMate | Défaut |
|---|---|---|---|---|---|---|
var_n1 |
Entier | Oui | Tout entier — supporte les références $variable |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | 0 |
var_n2 |
Entier | Oui | Tout entier — supporte les références $variable |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | 0 |
arithmetic_ops |
Entier | Oui | 1 (ADD), 2 (SUB), 3 (MUL), 4 (DIV), 5 (MOD), 6 (POW) |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | — |
Paramètres de sortie
| Champ | Type | Condition de déclenchement | Compatibilité Android | Compatibilité AndroMate | Défaut |
|---|---|---|---|---|---|
ops_output |
Entier (en chaîne) | Toujours — en cas de succès | Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | <ANDROMATE_NULL_VALUE> |
Exceptions
| Code | Déclenchement |
|---|---|
ARITHMETIC-OPS-001 |
Le code arithmetic_ops ne correspond à aucune opération supportée |
ARITHMETIC-OPS-002 |
var_n2 vaut 0 et l'opération est DIV (code 4) ou MOD (code 5) — division par zéro |
Diagramme d'exécution
flowchart TD
Start([▶ IntegerBinaryOps]) --> ResolveAll[🔄 Résoudre var_n1 et var_n2\ndepuis le contexte workflow]
ResolveAll --> ValidateOps{code arithmetic_ops connu ?}
ValidateOps -->|Non| E1[❌ ARITHMETIC-OPS-001\nOpérateur inconnu]
ValidateOps -->|Oui| Switch{arithmetic_ops}
Switch -->|1: ADD| AddOp["var_n1 + var_n2"]
Switch -->|2: SUB| SubOp["var_n1 - var_n2"]
Switch -->|3: MUL| MulOp["var_n1 × var_n2"]
Switch -->|4: DIV| DivCheck{var_n2 == 0 ?}
DivCheck -->|Oui| E2[❌ ARITHMETIC-OPS-002\nDivision par zéro]
DivCheck -->|Non| DivOp["var_n1 ÷ var_n2"]
Switch -->|5: MOD| ModCheck{var_n2 == 0 ?}
ModCheck -->|Oui| E2
ModCheck -->|Non| ModOp["var_n1 % var_n2"]
Switch -->|6: POW| PowOp["var_n1 ^ var_n2"]
AddOp --> WriteOutput[💾 Écrire résultat dans ops_output]
SubOp --> WriteOutput
MulOp --> WriteOutput
DivOp --> WriteOutput
ModOp --> WriteOutput
PowOp --> WriteOutput
WriteOutput --> Success([✅ TaskIntegerResult])
E1 --> Error([❌ Exception])
E2 --> Error
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Error fill:#ffcdd2
style E1 fill:#ffcdd2
style E2 fill:#ffcdd2
style ResolveAll fill:#fff9c4
style AddOp fill:#f3e5f5
style SubOp fill:#f3e5f5
style MulOp fill:#f3e5f5
style DivOp fill:#f3e5f5
style ModOp fill:#f3e5f5
style PowOp fill:#f3e5f5
style WriteOutput fill:#c8e6c9
Fonctionnement :
- Résoudre les opérandes :
var_n1etvar_n2sont résolus depuis le contexte workflow et analysés commeint - Valider l'opérateur : si
arithmetic_opsest inconnu, lanceARITHMETIC-OPS-001 - Vérifier la division par zéro : pour DIV et MOD, si
var_n2vaut0, lanceARITHMETIC-OPS-002 - Exécuter l'opération : l'opération arithmétique correspondante est appliquée
- Stocker le résultat : le résultat est écrit dans
ops_output - Résultat : retourne
TaskIntegerResulten cas de succès
Exemples de code
Exemple 1 — Additionner deux valeurs
{
"IntegerBinaryOps": [
{
"id": "1",
"title": "Latence totale",
"var_n1": "$rtt_dns",
"var_n2": "$rtt_http",
"arithmetic_ops": 1,
"ops_output": "$rtt_total"
}
]
}
Stocke $rtt_dns + $rtt_http dans $rtt_total.
Exemple 2 — Calculer une différence
{
"IntegerBinaryOps": [
{
"id": "2",
"title": "Delta RTT",
"var_n1": "$rtt_actuel",
"var_n2": "$rtt_reference",
"arithmetic_ops": 2,
"ops_output": "$delta_rtt"
}
]
}
Stocke $rtt_actuel - $rtt_reference dans $delta_rtt.
Exemple 3 — Division entière
{
"IntegerBinaryOps": [
{
"id": "3",
"title": "RTT moyen",
"var_n1": "$rtt_total",
"var_n2": "$nb_echantillons",
"arithmetic_ops": 4,
"ops_output": "$rtt_moyen"
}
]
}
Stocke $rtt_total ÷ $nb_echantillons (division entière) dans $rtt_moyen.
Exemple 4 — Puissance
{
"IntegerBinaryOps": [
{
"id": "4",
"title": "Puissance de deux",
"var_n1": "2",
"var_n2": "$exposant",
"arithmetic_ops": 6,
"ops_output": "$resultat"
}
]
}
Stocke 2 ^ $exposant dans $resultat.
Détails des paramètres d'entrée
1. Paramètre d'entrée : var_n1 — Opérande gauche
L'opérande entier gauche. Supporte les références $variable_workflow — résolu à l'exécution et analysé comme int.
- Défaut :
0 - Supporte les variables : Oui
2. Paramètre d'entrée : var_n2 — Opérande droit
L'opérande entier droit. Supporte les références $variable_workflow — résolu à l'exécution et analysé comme int.
Attention : ne doit pas valoir
0avec DIV (code 4) ou MOD (code 5) — déclencheARITHMETIC-OPS-002.
- Défaut :
0 - Supporte les variables : Oui
3. Paramètre d'entrée : arithmetic_ops — Code d'opération
Code entier sélectionnant l'opération binaire à appliquer entre var_n1 et var_n2.
| Code | Nom | Opération | Remarques |
|---|---|---|---|
1 |
ADD | var_n1 + var_n2 |
— |
2 |
SUB | var_n1 - var_n2 |
— |
3 |
MUL | var_n1 × var_n2 |
— |
4 |
DIV | var_n1 ÷ var_n2 |
Division entière — partie fractionnaire ignorée |
5 |
MOD | var_n1 % var_n2 |
Reste de la division entière |
6 |
POW | var_n1 ^ var_n2 |
Puissance (exponentiation) |
- Défaut : — (obligatoire, pas de défaut — déclenche
ARITHMETIC-OPS-001si inconnu)
Détails des paramètres de sortie
ops_output — Résultat de l'opération
Nom de la variable de workflow pour stocker le résultat entier. Doit être déclarée dans la tâche Start.
| Opération | Valeur écrite |
|---|---|
| ADD | var_n1 + var_n2 |
| SUB | var_n1 - var_n2 |
| MUL | var_n1 × var_n2 |
| DIV | var_n1 ÷ var_n2 (entier) |
| MOD | var_n1 % var_n2 |
| POW | var_n1 ^ var_n2 |
- Défaut :
""(résultat non stocké si vide)