You are using the wrong type: Swift Int does not necessarily correspond to Java Int because its size is platform dependent. Judging by your result, your platform uses 64-bit Int s. Here's how to confirm it:
println(sizeof(Int))
Int32 corresponds to Java Int . Sorry, this change
let int64: Int64 = 4253726258 let a:Int32 = Int32(int64)
may cause problems due to an error in the implementation of Swift.
If you need to sign an extended 32-bit value, you can do it as follows:
let int64: Int64 = 4253726258 let a:Int = Int((int64 << 32) >> 32) println(a)
Demo version
source share