Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local num = 5340789654
- function format(n)
- local n, f = math['modf'](num)
- local s, cc = "", 0;
- for pos, c in (tostring(n):reverse()):gmatch("()(.)") do
- s = s .. c
- cc = cc + 1
- if cc % 3 == 0 and pos ~= tostring(n):len() then
- s = s .. ","
- end
- end
- return s:reverse() .. tostring(f):sub(2)
- end
- print(format(num))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement