Contents

numericCast(_:)

Returns the given integer as the equivalent value in a different integer type.

Declaration

func numericCast<T, U>(_ x: T) -> U where T : BinaryInteger, U : BinaryInteger

Parameters

  • x:

    The integer to convert, an instance of type T.

Return Value

The value of x converted to type U.

Discussion

Calling the numericCast(_:) function is equivalent to calling an initializer for the destination type. numericCast(_:) traps on overflow in -O and -Onone builds.