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 : BinaryIntegerParameters
- 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.