Format number to separate thousands of values โโ(e.g. 12,000,000 becomes 12,000,000)
In lua, I would like to format an integer (or floating) number to divide every three decimal places by a space (or to whom, as in the US), so that for example the number 120000010 would be represented as 120,000 010 or 120000010
I found this one , but is there a way to achieve this using string.format or any other non-custom implementation related method?
source to share
printf
(and friends) can do this with (according to the man page) the format flag SUSv2
'
.
So does printf "%'d\n" 1000000
output 1,000,000
, but lua doesn't seem to support passing this through system calls printf
.
To clarify this answer, someone voted me. The answer here is "No". The only way to use string.format
for this is to use this flag, which as pointed out lua fails. So I don't know how to do this, without a custom solution like the one linked in the OP's question.
source to share