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
andrange.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 rangeReturn Value
Double
, representing a random percentage value within the min and maxrange
limits. -
A random percentage value between
range.min
andrange.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 rangemaxDecimalPlaces
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 maxrange
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 rangemaxDecimalPlaces
an optional configuration that limits the return value to the number of max places specified.
Return Value
Double
, representing a random percentage value not exceedingrange.max
.