Class UnitUtility
Static class for formatting functions for numbers with units or with extreme magnitudes.
Inheritance
System.Object
UnitUtility
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GDA
Assembly: Assembly-CSharp.dll
Syntax
public static class UnitUtility
Methods
FormatData(Single, UnitUtility.UnitType)
Formats a given number according to its Unit
Declaration
public static string FormatData(float amt, UnitUtility.UnitType unitType)
Parameters
Type | Name | Description |
---|---|---|
System. |
amt | Value to be formatted |
Unit |
unitType | Type of data the value is (Weight, Length, Area etc) |
Returns
Type | Description |
---|---|
System. |
FormatData(Single, UnitUtility.UnitType, Int32, Int32)
Formats a given number according to its Unit
Declaration
public static string FormatData(float amt, UnitUtility.UnitType unitType = UnitUtility.UnitType.Unitless, int decimalPlaces = 2, int sigFig = 3)
Parameters
Type | Name | Description |
---|---|---|
System. |
amt | Value to be formatted |
Unit |
unitType | Type of data the value is (Weight, Length, Area etc) |
System. |
decimalPlaces | Number decimal places that the value should have |
System. |
sigFig | Number of significant places that the value should have |
Returns
Type | Description |
---|---|
System. |
GetOrderOfMagnitude(Single)
Returns the order of magnitude of a number
Declaration
public static int GetOrderOfMagnitude(float amt)
Parameters
Type | Name | Description |
---|---|---|
System. |
amt |
Returns
Type | Description |
---|---|
System. |
Order of Magnitude |
GetUnitSymbol(Single, UnitUtility.UnitType)
Returns the units of a value as a string.
Declaration
public static string GetUnitSymbol(float amt, UnitUtility.UnitType unitType)
Parameters
Type | Name | Description |
---|---|---|
System. |
amt | |
Unit |
unitType |
Returns
Type | Description |
---|---|
System. |
Unit symbol (Kg, mL, etc) |