6-- Compatible with Lua 5.0 and 5.1.
7-- Disclaimer : use at own risk especially
for hedge fund reports :-)
9---============================================================
10-- add comma to separate thousands
23---============================================================
24-- rounds
a number to the nearest decimal places
28 return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
30 return math.floor(val+0.5)
34--===================================================================
35-- given
a numeric
value formats output with comma to separate thousands
36-- and rounded to given decimal places
40 local str_amount,
formatted, famount, remain
42 decimal = decimal or 2 -- default 2 decimal places
43 neg_prefix = neg_prefix or
"-" -- default negative sign
45 famount = math.abs(
self:Round(amount,decimal))
46 famount = math.floor(famount)
48 remain =
self:Round(math.abs(amount) - famount, decimal)
50 -- comma to separate the thousands
53 -- attach the decimal portion
55 remain = string.sub(tostring(remain),3)
57 string.rep(
"0", decimal - string.len(remain))
60 -- attach prefix string e.g
'$'
63 -- if
value is negative then format accordingly
65 if (neg_prefix==
"()") then
void processingNotification backgroundColor a()
Foundation for FrameworkZ.