Creates a new instance from the bit pattern of the given instance by truncating or sign-extending if needed to fit this type.
SDK
Xcode 9.0+
Framework
Swift Standard Library
Declaration
Parameters
source
An integer to convert to this type.
Discussion
When the bit width of T (the type of source) is equal to or greater than this type’s bit width, the result is the truncated least-significant bits of source. For example, when converting a 16-bit value to an 8-bit type, only the lower 8 bits of source are used.
When the bit width of T is less than this type’s bit width, the result is sign-extended to fill the remaining bits. That is, if source is negative, the result is padded with ones; otherwise, the result is padded with zeros.