Kingdaro

math rounding function

May 19th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.15 KB | None | 0 0
  1. function math.round(v,int)
  2.     int = (int==nil) and 1 or int
  3.     local n = math.fmod(v,int)
  4.    
  5.     if n >= int/2 then
  6.         return (v-n)+int
  7.     else
  8.         return (v-n)
  9.     end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment