CoronaSDK 2013.1143 | Released: 18 Jun 2013, 2:19am | What's New | Download Now
These docs are *very* out of date.
You will be redirected to the new docs in a few seconds.
If you are certain you want to see the old docs, click cancel.
Cancel | Continue to new docs
You will be redirected to the new docs in a few seconds.
If you are certain you want to see the old docs, click cancel.
Cancel | Continue to new docs
math.round()
Description:
Rounds number to the nearest integer following the same rules as the JavaScript version, i.e. if the fractional portion of number is .5 or greater, the argument is rounded to the next higher integer. If the fractional portion of number is less than .5, the argument is rounded to the next lower integer.
Syntax:
local value = math.round( num )
Example:
print( math.round( 0.1 ) ) -- Output: 0.1 0 print( math.round( 0.5 ) ) -- Output: 0.5 1 print( math.round( 8.9 ) ) -- Output: 8.9 9 print( math.round( -0.1 ) ) -- Output: -0.1 0 print( math.round( -0.5 ) ) -- Output: -0.5 0 print( math.round( -8.9 ) ) -- Output: -8.9 -9
Parameters:
num
Number to be rounded.
Returns:
number
Number rounded up or down.
Remarks:
Supported on operating systems and platforms for build numbers shown:
- Mac OS X:Build 2011.514
- Windows:Build 2011.514
- iOS:Build 2011.514
- Android:Build 2011.514

I don't think math.round is supported anymore. It gives me big greasy errors. I used math.floor instead.
-E