Double

extension Double

An extension for Double to allow easy conversion to other formats / values

  • Returns value converted to CGFloat.

    Declaration

    Swift

    public var cgFloatValue: CGFloat { get }
  • Returns value converted to Int.

    Declaration

    Swift

    public var intValue: Int { get }
  • A random percentage value.

    Note

    See Random.swift documentation for more information.

    Declaration

    Swift

    static func randomPercentage() -> Double

    Return Value

    Double, representing a random percentage value.

  • A random percentage value between range.min and range.max.

    Note

    See Random.swift documentation for more information.

    Declaration

    Swift

    static func randomPercentage(within range: PercentageRange) -> Double

    Parameters

    range

    a PercentageRange configuration that defines the min and max of the range

    Return Value

    Double, representing a random percentage value within the min and max range limits.

  • A random percentage value between range.min and range.max, limiting the number of decimal places to the value provided.

    Note

    See Random.swift documentation for more information.

    Declaration

    Swift

    static func randomPercentage(within range: PercentageRange, maxDecimalPlaces: Int) -> Double

    Parameters

    range

    a PercentageRange configuration that defines the min and max of the range

    maxDecimalPlaces

    an optional configuration that limits the return value to the number of max places specified.

    Return Value

    Double, representing a random percentage value within the min and max range limits.

  • A random percentage value between 0.0 and range.max, optionally rounded to a number of decimal places.

    Note

    See Random.swift documentation for more information.

    Declaration

    Swift

    static func randomPercentage(withUpperLimitOf range: PercentageRange, maxDecimalPlaces: Int?) -> Double

    Parameters

    range

    a PercentageRange configuration that defines the min and max of the range

    maxDecimalPlaces

    an optional configuration that limits the return value to the number of max places specified.

    Return Value

    Double, representing a random percentage value not exceeding range.max.