在 Xamarin.iOS 项目属性中,在“iOS 构建”下有一个选项:“将所有 32 位浮点操作执行为 64 位浮点”。
Microsoft似乎说使用 32 位“会影响精度,可能还会影响兼容性”,所以最好使用 64 位精度。
但是 Visual Studio 中文本上的弹出窗口(将光标悬停在“将所有 32 位浮点操作作为 64 位浮点数”上时)显示“使用 64 ......与 .net 代码略有不兼容”。
那么是哪一个呢?
最佳答案
您误读了第一点中的陈述。微软没有说使用 32 位是 坏 ,所以你需要使用64位。恰好相反。
基本上,最好使用 64 位浮点运算。它们是默认启用的,根据 Floating Point Operations in Xamarin.iOS docs :
While this higher precision is closer to what developers expect from floating point operations in C# on the desktop, on mobile, the performance impact can be significant.
让我们看看Code Analysis tool是:
Xamarin.iOS analysis is a set of rules that check your project settings to help you determine if better/more optimized settings are available.
因此,尽管最好使用 64 位浮点数,但这并不总是最佳选择。当您运行代码分析工具时,它会扫描您的项目以查看是否有更适合您的解决方案的配置(这取决于项目的流程)。
有时,64 位浮点数可能弊大于利。在这种情况下,linter 将使用
XIA0005: Float32Rule
警告您,这将建议您 取消选中 选项,就像微软的消息说的那样。
关于ios - "Perform all 32 bit float operations as 64 bit float"MORE 还是 LESS 与 .net 兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61821891/