Skip to content

Instantly share code, notes, and snippets.

@walterlua
Created May 18, 2011 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterlua/978164 to your computer and use it in GitHub Desktop.
Save walterlua/978164 to your computer and use it in GitHub Desktop.
Test case for math.round() function
math.round = function(num)
return math.floor(num+.5)
end
local function testRound( num )
print( num, math.round( num ) )
end
testRound( 0.1 )
testRound( 0.5 )
testRound( 0.9 )
testRound( 7.5 )
testRound( 8.9 )
testRound( -0.1 )
testRound( -0.5 )
testRound( -0.9 )
testRound( -7.5 )
testRound( -8.9 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment