ROUND()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a number rounded to the requested number of decimal places.
USAGE
ROUND(number[, count])
Argument Name | Description |
---|---|
| The number to be rounded |
| The desired number of decimal places |
DETAILS
ROUND()
is a mathematical function that rounds off a number
at the desired count
of decimal places and returns the result.
If is a count
is not specified, it defaults to 0
. This is equivalent to calling FLOOR().
If the count
is negative, the rounding continues past the decimal point. For instance, a count of -2
rounds to the value to hundreds.
If the count
is greater than the number of decimal points needed to display the value, it is padded with one or more trailing zeros.
The data type of the result is the same as the data type of the number
argument.
A NULL
is returned if either argument is NULL
.
EXAMPLES
SELECT ROUND(PI());
+-------------+
| ROUND(PI()) |
+-------------+
| 3 |
+-------------+
SELECT ROUND(-1.56);
+--------------+
| ROUND(-1.56) |
+--------------+
| -2 |
+--------------+
SELECT ROUND(1.123, 5);
+-----------------+
| ROUND(1.123, 5) |
+-----------------+
| 1.12300 |
+-----------------+