Template:Csn

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search

Comma Separated Number

Separates digits of an integer in groups of three by adding thousands separators; works for numbers under 1E15. Only positive numbers are supported, larger numbers are just provided in their standard output form.

Csn does some additional things that formatnum does not: rounding to an integer, removing leading zeros, removing - from -0, writing in scientific notation, computations.

  • 123
  • 1,234
  • 12,345
  • 123,456
  • 1,234,567
  • 12,345,678
  • 123,456,789
  • 1,234,567,890
Examples comparing csn and {{formatnum: number }}
"{{csn demo|-1}}" gives "-1       -1" [1]
"{{csn demo|-0}}" gives "0       -0" [2]
"{{csn demo|0.1}}" gives "0       0.1" [3]
"{{csn demo|1.23}}" gives "1       1.23" [4]
"{{csn demo|12.3}}" gives "12       12.3" [5]
"{{csn demo|6*20}}" gives "120       6*20" [6]
"{{csn demo|1234}}" gives "1,234       1,234" [7]
"{{csn demo|1230}}" gives "1,230       1,230" [8]
"{{csn demo|1200}}" gives "1,200       1,200" [9]
"{{csn demo|1000}}" gives "1,000       1,000" [10]
"{{csn demo|0000}}" gives "0       0,000" [11]
"{{csn demo|12345.67890123456}}" gives "12,346       12,345.67890123456" [12]
"{{csn demo|123456.7890123456}}" gives "123,457       123,456.7890123456" [13]
"{{csn demo|1234567.890123456}}" gives "1,234,568       1,234,567.890123456" [14]
"{{csn demo|12345678.90123456}}" gives "12,345,679       12,345,678.90123456" [15]
"{{csn demo|123456789.0123456}}" gives "123,456,789       123,456,789.0123456" [16]
"{{csn demo|1234567890.123456}}" gives "1,234,567,890       1,234,567,890.123456" [17]
"{{csn demo|12345678901.23456}}" gives "12,345,678,901       12,345,678,901.23456" [18]
"{{csn demo|123456789012.3456}}" gives "123,456,789,012       123,456,789,012.3456" [19]
"{{csn demo|1234567890123.456}}" gives "1,234,567,890,123       1,234,567,890,123.456" [20]
"{{csn demo|12345678901234.56}}" gives "12,345,678,901,235       12,345,678,901,234.56" [21]
"{{csn demo|123456789012345.6}}" gives "123,456,789,012,346       123,456,789,012,345.6" [22]
"{{csn demo|1234567890123456.}}" gives "1.2345678901235E+15       1,234,567,890,123,456." [23]
"{{csn demo|12}}" gives "12       12" [24]
"{{csn demo|1234}}" gives "1,234       1,234" [25]
"{{csn demo|123456}}" gives "123,456       123,456" [26]
"{{csn demo|12345678}}" gives "12,345,678       12,345,678" [27]
"{{csn demo|1234567890}}" gives "1,234,567,890       1,234,567,890" [28]
"{{csn demo|123456789012}}" gives "123,456,789,012       123,456,789,012" [29]
"{{csn demo|12345678901234}}" gives "12,345,678,901,234       12,345,678,901,234" [30]

{{subst:csn|123456789012345}} gives the wikitext 123,456,789,012,345

{{subst:formatnum:123456789012345}} gives the wikitext 123,456,789,012,345

"{{csn demo|1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17}}" gives "355,687,428,096,000       1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17" [31].