MOD |
Modulo |
|---|---|
| Sybase |
Syntaxe
| Mod(Nombre1,Nombre2) |
Paramètres
| Nom | Description |
|---|---|
| Nombre1 | Ce paramètre permet d'indiquer l'expression contenant le nombre à traiter |
| Nombre2 | Ce paramètre permet d'indiquer le diviseur |
Description
Cette fonction retourne la partie restante d'un nombre (le modulo).
Exemple
Voici un exemple montrant une utilisation plus classique de cette fonction :
- SELECT 'mod(-81,9)=' As Text, mod(-81,9) AS Result UNION
- SELECT 'mod(15,3) = ' As Text,mod(15,3) As Result UNION
- SELECT 'mod(16,3) = ' As Text, mod(16,3) AS Result UNION
- SELECT 'mod(16.9,3) = ' As Text,mod(16.9,3) As Result UNION
- SELECT 'mod(16.8,3) = ' As Text,mod(16.8,3) As Result UNION
- SELECT 'mod(16.7,3) = ' As Text,mod(16.7,3) As Result UNION
- SELECT 'mod(16.6,3) = ' As Text,mod(16.6,3) As Result UNION
- SELECT 'mod(16.5,3) = ' As Text,mod(16.5,3) As Result UNION
- SELECT 'mod(16.4,3) = ' As Text,mod(16.4,3) As Result UNION
- SELECT 'mod(16.3,3) = ' As Text,mod(16.3,3) As Result UNION
- SELECT 'mod(16.2,3) = ' As Text,mod(16.2,3) As Result UNION
- SELECT 'mod(16.1,3) = ' As Text,mod(16.1,3) As Result UNION
- SELECT 'mod(17,3) = ' As Text,mod(17,3) As Result UNION
- SELECT 'mod(18,3) = ' As Text,mod(18,3) As Result UNION
- SELECT 'mod(19,3) = ' As Text,mod(19,3) As Result UNION
- SELECT 'mod(0,1) = ' As Text,mod(0,1) As Result
on obtiendra le résultat suivant :
| Text | Result |
| mod(-81,9)= | 0.0 |
| mod(15,3) = | 0.0 |
| mod(16,3) = | 1.0 |
| mod(16.9,3) = | 1.9 |
| mod(16.8,3) = | 1.8 |
| mod(16.7,3) = | 1.7 |
| mod(16.6,3) = | 1.6 |
| mod(16.5,3) = | 1.5 |
| mod(16.4,3) = | 1.4 |
| mod(16.3,3) = | 1.3 |
| mod(16.2,3) = | 1.2 |
| mod(16.1,3) = | 1.1 |
| mod(17,3) = | 2.0 |
| mod(18,3) = | 0.0 |
| mod(19,3) = | 1.0 |
| mod(0,1) = | 0.0 |
Dernière mise à jour : Dimanche, le 31 mai 2015