This language bar is your friend. Select your favorite languages!

Idiom #173 Format a number with grouped thousands

Number will be formatted with a comma separator between every group of thousands.

format(1000, ',')
f'{1000:,}'
'{:,}'.format(1000)
#define _POSIX_C_SOURCE 200809L
#include <locale.h>
#include <stdio.h>
setlocale(LC_ALL, "");
printf("%'d\n", 1000);
import std.format;
string f = "%3,d".format(123456);
import "golang.org/x/text/language"
import "golang.org/x/text/message"
p := message.NewPrinter(language.English)
s := p.Sprintf("%d\n", 1000)
(1000).toLocaleString();
new Intl.NumberFormat().format(1000);
echo number_format(1000);
sysutils
writeln(format('%.0n',[double(10000)]));   
'1000'.reverse.scan(/.{1,3}/).join(',').reverse
require 'active_support/all'
1000.to_s(:delimited)
'1000'.gsub(/\B(?=(...)*\b)/, ',')

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

cup