What's the recommended way to print an integer with thousands separator? Best I've come up with so far is
let thousands(x:int64) = String.Format("{0:0,0}", x)
Which works in most cases, but prints zero as 00.
The formatting token for a decimal place in .NET is "." regardless of the culture that the assembly is using, and "," for the thousand separator. However different cultures (for example France) use "," for decimal places, so that might be an issue to consider.
Here's some (C#) examples:
C
£N
£#,#
double x = 67867987.88666;
Console.WriteLine("{0:C}",x);
Console.WriteLine("£{0:N}", x);
Console.WriteLine("£{0:#,#.###}", x);
Output:
£67,867,987.89
£67,867,987.89
£67,867,987.887
More details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With