In MariaDB, TAN() è una funzione numerica incorporata che restituisce la tangente del suo argomento.
Sintassi
La sintassi è questa:
TAN(X)
Dove X è il numero per cui restituire la tangente.
Esempio
Ecco un esempio:
SELECT TAN(1.5672); Risultato:
+-------------------+ | TAN(1.5672) | +-------------------+ | 278.0602948059405 | +-------------------+
Ecco altri esempi:
SELECT
TAN(0),
TAN(1),
TAN(PI()); Risultato:
+--------+-------------------+-------------------------+ | TAN(0) | TAN(1) | TAN(PI()) | +--------+-------------------+-------------------------+ | 0 | 1.557407724654902 | -1.2246467991473532e-16 | +--------+-------------------+-------------------------+
Argomento negativo
Gli argomenti negativi sono perfettamente validi.
Esempio:
SELECT TAN(-2.17873); Risultato:
+--------------------+ | TAN(-2.17873) | +--------------------+ | 1.4370963009569087 | +--------------------+
Argomento non numerico
Ecco cosa succede quando forniamo un argomento non numerico:
SELECT TAN('Two'); Risultato:
+------------+
| TAN('Two') |
+------------+
| 0 |
+------------+
1 row in set, 1 warning (0.000 sec) Controlliamo l'avviso:
SHOW WARNINGS; Risultato:
+---------+------+-----------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'Two' | +---------+------+-----------------------------------------+
Conteggio argomenti non valido
Chiamando TAN() senza un argomento genera un errore:
SELECT TAN(); Risultato:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'TAN'
E:
SELECT TAN(1, 2); Risultato:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'TAN'