Skip to content

Instantly share code, notes, and snippets.

@seebs
Created May 15, 2015 21:28
Show Gist options
  • Save seebs/bee7f16238782adc05b4 to your computer and use it in GitHub Desktop.
Save seebs/bee7f16238782adc05b4 to your computer and use it in GitHub Desktop.
round function test case (from IRC discussion)
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