IotaUnitsConverter

public struct IotaUnitsConverter

Utils for unit conversion.

  • Converts from Iota to the specified unit.

    Declaration

    Swift

    public static func convert(amount: UInt64, toUnit unit: IotaUnits) -> Double

    Parameters

    amount

    The amount in Iota.

    unit

    The final unit.

    Return Value

    The value in the specified unit.

  • Converts from arbitrary unit to the specified unit.

    Declaration

    Swift

    public static func convert(amount: Double, fromUnit: IotaUnits, toUnit: IotaUnits) -> Double

    Parameters

    amount

    The amount.

    fromUnit

    The arbitrary unit.

    toUnit

    The final unit.

    Return Value

    The value in the specified unit.

  • Converts Iota amount to human readable string.

    Declaration

    Swift

    public static func iotaToString(amount: UInt64, extended: Bool = false, forceUnit: IotaUnits? = nil) -> String

    Parameters

    amount

    The amount.

    extended

    If true, will return the extended string.

    forceUnit

    An arbitrary unit.

    Return Value

    The string that represents the value and unit.