FloatingPoint
extension FloatingPoint
-
Returns
replacementifself.isInfiniteistrue, orselfifselfis finite.Declaration
Swift
public func replacingInfinity(with replacement: Self) -> Self -
Rounds this value to the specified scale, where the scale is the number of rounding stops per integer.
A rounding scale of 1.0 is standard integer rounding. A rounding scale of 2.0 rounds to halves (0, 0.5, 1.0, 1.5, 2.0, 2.5., …). A rounding scale of 3.0 rounds to thirds (0, 1/3, 2/3, 1.0, 4/3, 5/3, 2.0, …).
Declaration
Swift
public mutating func round(_ rule: FloatingPointRoundingRule, by scale: Self)Parameters
rulethe rounding rule
scalethe rounding scale
-
Returns this value rounded to the specified scale, where the scale is the number of rounding stops per integer.
A rounding scale of 1.0 is standard integer rounding. A rounding scale of 2.0 rounds to halves (0, 0.5, 1.0, 1.5, 2.0, 2.5., …). A rounding scale of 3.0 rounds to thirds (0, 1/3, 2/3, 1.0, 4/3, 5/3, 2.0, …).
Declaration
Swift
public func rounded(_ rule: FloatingPointRoundingRule, by scale: Self) -> SelfParameters
rulethe rounding rule
scalethe rounding scale
Return Value
The rounded value.
View on GitHub
FloatingPoint Extension Reference