Created
May 18, 2011 07:53
-
-
Save walterlua/978164 to your computer and use it in GitHub Desktop.
Test case for math.round() function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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