mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(imports/math): groupdigits (#338)
This commit is contained in:
@@ -90,4 +90,13 @@ function math.tohex(n, upper)
|
||||
return upper and n:upper() or n
|
||||
end
|
||||
|
||||
return lib.math
|
||||
---Converts input number into grouped digits
|
||||
---@param number number
|
||||
---@param seperator? string
|
||||
---@return string
|
||||
function math.groupdigits(number, seperator) -- credit http://richard.warburton.it
|
||||
local left,num,right = string.match(number,'^([^%d]*%d)(%d*)(.-)$')
|
||||
return left..(num:reverse():gsub('(%d%d%d)','%1' .. (seperator or ',')):reverse())..right
|
||||
end
|
||||
|
||||
return lib.math
|
||||
Reference in New Issue
Block a user