我正在将项目从Java转换为Swift.我的Java代码使用小数据类型(short,byte).我应该使用Int16,Int8等同于斯威夫特,或者只使用Int类型呢?内存优化和速度在哪里?
我试图将我的代码从java转换为swift,但是当使用Int类型执行shift右运算符时,得到2个diffrence结果.
// java的
int d = 25;
int x = d >> 1 + 1;
System.out.println(x); //output: 6
Run Code Online (Sandbox Code Playgroud)
// swift(4)
let d = 25
let x = d >> 1 + 1
print(x) //output: 13
Run Code Online (Sandbox Code Playgroud)
什么是快速代码的解决方案?