Initializerswift 6.0.1Swift

    init(_:)

    Creates a new instance that approximates the given value.

    iOS
    14.0+
    macOS
    11.0+
    tvOS
    14.0+
    watchOS
    7.0+
    init(_ other: Float)

    Parameters

    other

    The value to use for the new instance.

    The value of other is rounded to a representable value, if necessary. A NaN passed as other results in another NaN, with a signaling NaN value converted to quiet NaN.

    let x: Float = 21.25
    let y = Float16(x)
    // y == 21.25
    
    let z = Float16(Float.nan)
    // z.isNaN == true

    Other members in extension

    Types

    Typealiases

    Type members

    Instance members