Tokio Posted March 4, 2018 Share Posted March 4, 2018 For example, when i have 1.000.000$ convert to: 1M$, or if i have 2.400.000$ convert to: 2.44M$. How to make this possible? Link to comment
Tokio Posted March 4, 2018 Author Share Posted March 4, 2018 41 minutes ago, ZL|LuCaS said: can you string.format How? Link to comment
NeXuS™ Posted March 4, 2018 Share Posted March 4, 2018 (edited) local moneySuff = {"K", "M", "B", "T", "Q"} function convertMoney(cMoney) didConvert = 0 if not cMoney then return "?" end while cMoney / 1000 >= 1 do cMoney = cMoney / 1000 didConvert = didConvert + 1 end if didConvert > 0 then return "$" .. string.format("%.2f", cMoney) .. moneySuff[didConvert] else return "$" .. cMoney end end Edited March 4, 2018 by NeXuS™ 1 1 Link to comment
Tokio Posted March 4, 2018 Author Share Posted March 4, 2018 5 minutes ago, NeXuS™ said: local moneySuff = {"K", "M", "B", "T", "Q"} function convertMoney(cMoney) didConvert = 0 if not cMoney then return "?" end while cMoney / 1000 >= 1 do cMoney = cMoney / 1000 didConvert = didConvert + 1 end if didConvert > 0 then return "$" .. string.format("%.2f", cMoney) .. moneySuff[didConvert] else return "$" .. cMoney end end thank you:D Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now