Show / Hide Table of Contents

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 UnitUtility.UnitType

Declaration
public static string FormatData(float amt, UnitUtility.UnitType unitType)
Parameters
Type Name Description
System.Single amt

Value to be formatted

UnitUtility.UnitType unitType

Type of data the value is (Weight, Length, Area etc)

Returns
Type Description
System.String

FormatData(Single, UnitUtility.UnitType, Int32, Int32)

Formats a given number according to its UnitUtility.UnitType

Declaration
public static string FormatData(float amt, UnitUtility.UnitType unitType = UnitUtility.UnitType.Unitless, int decimalPlaces = 2, int sigFig = 3)
Parameters
Type Name Description
System.Single amt

Value to be formatted

UnitUtility.UnitType unitType

Type of data the value is (Weight, Length, Area etc)

System.Int32 decimalPlaces

Number decimal places that the value should have

System.Int32 sigFig

Number of significant places that the value should have

Returns
Type Description
System.String

GetOrderOfMagnitude(Single)

Returns the order of magnitude of a number

Declaration
public static int GetOrderOfMagnitude(float amt)
Parameters
Type Name Description
System.Single amt
Returns
Type Description
System.Int32

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.Single amt
UnitUtility.UnitType unitType
Returns
Type Description
System.String

Unit symbol (Kg, mL, etc)

In This Article
Back to top Generated by DocFX