Yuari
Documentation
Docs/Core functions/math.round

math.round

Rounds to the nearest integer, halves away from zero.

Syntax

math.round(x: number) -> number

Parameters

ParameterTypeDescription
xnumberValue to round.

Returns

TypeDescription
numberNearest integer as a float.

Description

Uses the Luau rule, so 0.5 rounds to 1 and -0.5 to -1 rather than toward zero.

The result is a number, not an integer subtype.

Example

print(math.round(2.4))   -- 2
print(math.round(2.5))   -- 3
print(math.round(-2.5))  -- -3

Notes

  • math.floor(x + 0.5) — Differs for negative halves; prefer math.round.