FloatingPoint

extension FloatingPoint
  • Returns replacement if self.isInfinite is true, or self if self is 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

    rule

    the rounding rule

    scale

    the 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) -> Self

    Parameters

    rule

    the rounding rule

    scale

    the rounding scale

    Return Value

    The rounded value.