Initializerswift 6.0.1Swift

    init(exactly:)

    Creates a new instance initialized to the given value, if it can be represented without rounding.

    init?(exactly other: Double)

    Parameters

    other

    The value to use for the new instance.

    If other can’t be represented as an instance of Double without rounding, the result of this initializer is nil. In particular, passing NaN as other always results in nil.

    let x: Double = 21.25
    let y = Double(exactly: x)
    // y == Optional.some(21.25)
    
    let z = Double(exactly: Double.nan)
    // z == nil

    Other members in extension

    Types

    Typealiases

    Type members

    Instance members

    Show obsolete interfaces (1)

    Hide obsolete interfaces