Math.round

From GiderosMobile
Revision as of 18:49, 16 January 2023 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2022.1<br/> '''Class:''' math<br/> === Description === Returns the integer with the smallest difference between it and the given...")
(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