Reputation: 113
I'm using libraries with C interface in swift and in C error codes often are set with hexadecimal defines corresponded to signed integer values.
Is there any ways to set hexadecimal literal to signed integer type, for example:
var k: Int32 = 0x80000001
?
Upvotes: 0
Views: 317
Reputation: 17872
There's a special initializer for just this case:
let x = Int32(bitPattern: 0x80000001)
print(x) // -2147483647
Upvotes: 2