DecimalFormat f = (DecimalFormat) getNumberInstance();
f.setGroupingSize(3);
String s = f.format(1_000);
out.printf("%,f", new BigDecimal("1234.5"));
out.printf("%,d", new BigInteger("1234"));
out.printf("%,f", 1_234.5);
NumberFormat f = new DecimalFormat("#,###");
String s = f.format(1_234);
String.format("%,d", 1000000);
setlocale(LC_ALL, "");
printf("%'d\n", 1000);
string f = "%3,d".format(123456);
p := message.NewPrinter(language.English)
s := p.Sprintf("%d\n", 1000)
s :: Int -> String
s = intersperseN ',' 3 . show
intersperseN :: a -> Int -> [a] -> [a]
intersperseN x n = uncurry (<>) . foldr alg ([], [])
where
alg a (buf', acc)
| length buf >= n = ([], (x:buf) <> acc)
| otherwise = (buf, acc)
where buf = a:buf'
new Intl.NumberFormat().format(1000);
echo number_format(1000);
writeln(format('%.0n',[double(10000)]));
sub commify {
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
'1000'.gsub(/\B(?=(...)*\b)/, ',')
'1000'.reverse.scan(/.{1,3}/).join(',').reverse
println!("{}", 1000.separated_string());