# ROUND

## Syntax

```
ROUND(X), ROUND(X,D)
```

## Description

Rounds the argument `X` to `D` decimal places. `D` defaults to `0` if not specified.`D` can be negative to cause `D` digits left of the decimal point of the value `X` to become zero.

The rounding algorithm depends on the data type of `X`:

* For floating-point types ([FLOAT](https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float), [DOUBLE](https://mariadb.com/docs/server/reference/data-types/numeric-data-types/double)) the C libraries rounding function is used, so the behavior *may* differ between operating systems.
* For fixed-point types ([DECIMAL](https://mariadb.com/docs/server/reference/data-types/numeric-data-types/decimal), [DEC/NUMBER/FIXED](https://mariadb.com/docs/server/reference/data-types/numeric-data-types/dec-numeric-fixed)) the "round half up" rule is used, meaning that e.g. a value ending in exactly .5 is always rounded up.

## Examples

```sql
SELECT ROUND(-1.23);
+--------------+
| ROUND(-1.23) |
+--------------+
|           -1 |
+--------------+

SELECT ROUND(-1.58);
+--------------+
| ROUND(-1.58) |
+--------------+
|           -2 |
+--------------+

SELECT ROUND(1.58); 
+-------------+
| ROUND(1.58) |
+-------------+
|           2 |
+-------------+

SELECT ROUND(1.298, 1);
+-----------------+
| ROUND(1.298, 1) |
+-----------------+
|             1.3 |
+-----------------+

SELECT ROUND(1.298, 0);
+-----------------+
| ROUND(1.298, 0) |
+-----------------+
|               1 |
+-----------------+

SELECT ROUND(23.298, -1);
+-------------------+
| ROUND(23.298, -1) |
+-------------------+
|                20 |
+-------------------+
```

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/round.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
