Math.round

From GiderosMobile
Revision as of 14:31, 13 July 2023 by Hgy29 (talk | contribs) (Text replacement - "</source>" to "</syntaxhighlight>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2022.1
Class: math

Description

Returns the integer with the smallest difference between it and the given number.

(number) = math.round(v)

For example, the value 5.8 returns 6.

For values like 0.5 that are equidistant to two integers, the value with the greater difference between it and zero is chosen. In other words, the function rounds away from zero: 0.5 rounds to 1; -0.5 rounds to -1.

Parameters

v: (number) value to round

Return values

Returns (number) rounding result