Created
May 15, 2015 21:28
-
-
Save seebs/bee7f16238782adc05b4 to your computer and use it in GitHub Desktop.
round function test case (from IRC discussion)
This file contains hidden or 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
local floor = math.floor | |
function rd(x, d) | |
return floor(x * d * 10) / (d * 10) | |
end | |
function tst(x, d) | |
local r = rd(x, d) | |
print(string.format("rd(%s, %s) => %s", tostring(x), tostring(d), tostring(r))) | |
end | |
tst(0.40, 1) | |
tst(0.35, 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment