> On May 26, 2017, at 12:04 AM, Xiaodi Wu via swift-evolution
> <[email protected]> wrote:
>
> I've often wondered if even just "bitPattern" might suffice, as the
> truncating or extending of it should not be particularly surprising.
Being explicit about bit pattern truncation or extension is valuable. It helps
catch bugs where the bit count is not what the author expected. In Swift it is
especially important for types like Int and CGFloat which have
platform-dependent sizes.
let x: Int64 = …
let y = Int(bitPattern: x) // if truncation is implicit then this may be
surprising on 32-bit platforms
let a: UInt32 = …
let b = Int(bitPattern: a) // if zero- or sign-extension is implicit then
this may be surprising on 64-bit platforms
--
Greg Parker [email protected] <mailto:[email protected]> Runtime
Wrangler
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution