FactoryPlanner
FactoryPlanner copied to clipboard
Optimize format_number and format_SI_value
Also, maaaybe they can accomodate a functionality to format the same number to different precisions in one go, which is needed in several spots. Also add thousands-place separators to the format function. Also give an indication whether the number was rounded/cut off or not (~)
Curi proposes this method for display formatting:
local function number_to_string_with_precision(number, precision)
local result = tostring(number)
if precision > 0 then
local rounded = format(format('%%.%if', precision), number)
if strlen(rounded) < strlen(result) then
result = rounded
end
end
return result
end