DIVFLT()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Return the floating point value of one number divided by another.
USAGE
DIVFLT(dividend, divisor)
Argument Name | Description |
---|---|
| The numbers in the division |
| The numbers in the division |
DETAILS
DIVFLT()
is a mathematical function that computes a floating point result of dividing the dividend by the divisor. The DIVFLT()
function is similar to the /
operator.
A NULL
is returned if the divisor is 0 or if either of the arguments is NULL
.
Because the returned value is not rounded down, the result of DIVFLT(x, y)
is not the same as FLOOR(DIVFLT(x, y))
when the resulting value is negative.
To obtain the integer result of a division operation, see "DIV" or "DIVINT()".
EXAMPLES
SELECT DIVFLT(12345, 10), DIVFLT(22, 3), DIVFLT(.5, .25);
+-------------------+---------------+-----------------+
| DIVFLT(12345, 10) | DIVFLT(22, 3) | DIVFLT(.5, .25) |
+-------------------+---------------+-----------------+
| 1234.5000 | 7.3333 | 2.00000 |
+-------------------+---------------+-----------------+
CREATE TABLE div_flt_example (
val INT
);
INSERT INTO div_flt_example VALUES
(21), (22), (23), (24), (25), (26), (27), (28),
(-21), (-22), (-23), (-24), (-25), (-26), (-27), (-28);
SELECT val, DIVFLT(val, 7), val DIV 7, FLOOR(val / 7)
FROM div_flt_example;
+------+----------------+-----------+----------------+
| val | DIVFLT(val, 7) | val DIV 7 | FLOOR(val / 7) |
+------+----------------+-----------+----------------+
| 21 | 3.0000 | 3 | 3 |
| 22 | 3.1429 | 3 | 3 |
| 23 | 3.2857 | 3 | 3 |
| 24 | 3.4286 | 3 | 3 |
| 25 | 3.5714 | 3 | 3 |
| 26 | 3.7143 | 3 | 3 |
| 27 | 3.8571 | 3 | 3 |
| 28 | 4.0000 | 4 | 4 |
| -21 | -3.0000 | -3 | -3 |
| -22 | -3.1429 | -3 | -4 |
| -23 | -3.2857 | -3 | -4 |
| -24 | -3.4286 | -3 | -4 |
| -25 | -3.5714 | -3 | -4 |
| -26 | -3.7143 | -3 | -4 |
| -27 | -3.8571 | -3 | -4 |
| -28 | -4.0000 | -4 | -4 |
+------+----------------+-----------+----------------+