I need a way to format numbers. I stored some numbers in my DB table, e.g. 12500, and would like to print them in this format 12 500 (so there is a
I just stumbled on this thread while looking for a way to format a value as US currency. I took a slightly different approach to the regex solutions proposed:
amt = 1234567890.12
f_amt = format("$%.2f",amt)
i = f_amt.index(".")
while i > 4
f_amt[i-3]=","+f_amt[i-3]
i = f_amt.index(",")
end
f_amt
=> "$1,234,567,890.12"
This could be parameterized for formatting other currencies.