iPhone 上的双与浮动 [英] Double vs float on the iPhone

查看:22
本文介绍了iPhone 上的双与浮动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚听说 iphone 不能在本机上执行 double 从而使它们比常规浮点速度慢得多.

I have just heard that the iphone cannot do double natively thereby making them much slower that regular float.

这是真的吗?证据?

我对这个问题很感兴趣,因为我的程序需要高精度计算,我将不得不在速度上妥协.

I am very interested in the issue because my program needs high precision calculations, and I will have to compromise on speed.

推荐答案

iPhone 可以在硬件中进行单精度和双精度运算.在 1176(原始 iPhone 和 iPhone3G)上,它们以大致相同的速度运行,但您可以在缓存中放入更多单精度数据.在 Cortex-A8(iPhone3GS、iPhone4 和 iPad)上,单精度运算是在 NEON 单元上完成的,而不是在 VFP 上完成,并且速度明显更快.

The iPhone can do both single and double precision arithmetic in hardware. On the 1176 (original iPhone and iPhone3G), they operate at approximately the same speed, though you can fit more single-precision data in the caches. On the Cortex-A8 (iPhone3GS, iPhone4 and iPad), single-precision arithmetic is done on the NEON unit instead of VFP, and is substantially faster.

如果您正在进行密集的浮点计算,请确保在 armv6 的编译设置中关闭拇指模式.

Make sure to turn off thumb mode in your compile settings for armv6 if you are doing intensive floating-point computation.

这篇关于iPhone 上的双与浮动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆