CostTypeFormat Method |
Namespace: KSPDev.GUIUtils.TypeFormatters
public static string Format( double value, string format = null )
The method tries to keep the resulted string meaningful and as short as possible. For this reason the big values may be scaled down and/or rounded.
There is no well established unit for measuring the costs in the game. However, there is a commonly used literal that denotes the costs: √. This literal is used as the base (and the only) unit name. It's assumed that the values below 0.01 don't makes sense from the financial perspective, so they are not attempted to be presented.
Debug.Log(CostType.Format(0.4)); // Prints: "Cost is: √ 0.40" Debug.Log(CostType.Format(0.41)); // Prints: "Cost is: √ 0.41" Debug.Log(CostType.Format(1.0)); // Prints: "Cost is: √ 1.00" Debug.Log(CostType.Format(1.41)); // Prints: "Cost is: √ 1.41" Debug.Log(CostType.Format(1234.555)); // Prints: "Cost is: √ 1,234.56"
Debug.Log(CostType.Format(1234.5678, format: "0.0000")); // Prints: "√ 1234.5678" Debug.Log(CostType.Format(1234.5678, format: "#,##0.00")); // Prints: "√ 1,234.57"