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

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

问题描述

我刚刚听说 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上的双倍vs浮动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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