Difference between revisions of "Template:Format Number"

From RimWorld Wiki
Jump to navigation Jump to search
(Created page with "<includeonly>{{#switch: {{{2|}}} | Integer = {{#expr: {{{1|}}} round 0}} | FloatOne | FloatMaxOne = {{#expr: {{{1|}}} round 1}} | FloatTwo...")
 
m (Include FloatThree, even though so far it is unused)
 
Line 1: Line 1:
 
<includeonly>{{#switch: {{{2|}}}
 
<includeonly>{{#switch: {{{2|}}}
  | Integer                         = {{#expr: {{{1|}}} round 0}}
+
  | Integer           = {{#expr: {{{1|}}} round 0}}
  | FloatOne | FloatMaxOne         = {{#expr: {{{1|}}} round 1}}
+
  | FloatOne
  | FloatTwo | FloatMaxTwo         = {{#expr: {{{1|}}} round 2}}
+
| FloatMaxOne       = {{#expr: {{{1|}}} round 1}}
  | FloatTwoOrThree | FloatMaxThree = {{#expr: {{{1|}}} round 3}}
+
  | FloatTwo
 +
| FloatMaxTwo       = {{#expr: {{{1|}}} round 2}}
 +
  | FloatThree
 +
| FloatMaxThree
 +
| FloatTwoOrThree  = {{#expr: {{{1|}}} round 3}}
 
  | PercentZero      = {{%|{{{1|}}}|0}}
 
  | PercentZero      = {{%|{{{1|}}}|0}}
 
  | PercentOne        = {{%|{{{1|}}}|1}}
 
  | PercentOne        = {{%|{{{1|}}}|1}}

Latest revision as of 20:15, 1 October 2024

Documentation icon Template documentation

Usage

This template is used to simplify formating numbers in the Template:Stat. Is is used like this:

{{Format Number|<number>|<toStringStyle>}}

Examples

  • {{Format Number|1.1111|Integer}} => 1
  • {{Format Number|1.1111|FloatOne}} or {{Format Number|1.1111|FloatMaxOne}} => 1.1
  • {{Format Number|1.1111|FloatTwo}} or {{Format Number|1.1111|FloatMaxTwo}} => 1.11
  • {{Format Number|1.1111|FloatTwoOrThree}} or {{Format Number|1.1111|FloatMaxThree}} => 1.111
  • {{Format Number|1.1111|PercentZero}} => 111%
  • {{Format Number|1.1111|PercentOne}} => 111.1%
  • {{Format Number|1.1111|PercentTwo}} => 111.11%
  • {{Format Number|24|Temperature}} => 24 °C (75.2 °F)
  • {{Format Number|24|TemperatureOffset}} => 24 °C (43.2 °F)
  • {{Format Number|24|Money}} => 24 Silver
  • {{Format Number|24|WorkAmount}} => 24 ticks (0.4 secs)