iPhone / iPad的双precision数学 [英] iPhone/iPad double precision math

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

问题描述

接受的答案这个社区维基问题:<一href=\"http://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa\">What是你写的Objective-C和Cocoa时所使用的最佳实践?说,iPhone手机不能做双precision数学(或者更确切地说,他们可以,但只有在软件仿真的)。不幸的是,2009年它的链接提供作为参考:双VS浮在iPhone 直接违背这一声明。这两个都老了,被写入当3GS刚刚出来了。

The accepted answer to this Community Wiki question: What are best practices that you use when writing Objective-C and Cocoa? says that iPhones can't do double precision math (or rather, they can, but only emulated in software.) Unfortunately the 2009 link it provides as a reference: Double vs float on the iPhone directly contradicts that statement. Both of these are old, being written when the 3GS was just coming out.

那么,什么是与最新的ARM7架构的故事吗?我是否需要担心'拇指'编译器标志的第二个链接引用?我可以放心地使用双击变量?我有讨厌的倒叙386SXs和台DX和黑暗的日子数学协处理器。告诉我这是2012年,我们已经前进了。

So what's the story with the latest arm7 architecture? Do I need to worry about the 'thumb' compiler flag the second link references? Can I safely use double variables? I am having nasty flashbacks to dark days of 386SXs and DXs and 'math coprocessors.' Tell me it's 2012 and we've moved on.

推荐答案

在所有的iPhone手机,没有理由双重precision不予支持。它们都使用的Cortex-A8架构的协处理器CP15(这在硬件上支持IEEE float和double计算)。

In all of the iPhones, there is no reason double precision shouldn't be supported. They all use Cortex-A8 architecture with the cp15 coprocessor (which supports IEEE float and double calculations in hardware).

<一个href=\"http://www.arm.com/products/processors/technologies/vector-floating-point.php\">http://www.arm.com/products/processors/technologies/vector-floating-point.php

所以,是的,你可以放心地使用双打和它不应该是软件仿真的iPhone手机。
虽然这是在硬件中完成,它可能还需要更多的周期来执行双重mathemtic算术VS单(浮动)。除了使用双,我会检查,以确保precision是适合你的应用。

So yes, you can safely use doubles and it shouldn't be software emulated on the iPhones. Although this is done in hardware, it may still take more cycles to perform double mathemtic arithmatic vs single (float). In addition to using double, I would check to make sure the precision is appropriate for your application.

作为一个方面说明,如果处理器支持NEON指令集,双打和彩车可以计算比使用协处理器速度更快。

As a side note, if the processor supports NEON instruction set, doubles and floats may be calculated faster than using the coprocessor.

<一个href=\"http://pandorawiki.org/Floating_Point_Optimization#Compiler_Support\">http://pandorawiki.org/Floating_Point_Optimization#Compiler_Support

编辑:虽然VFP和霓虹灯是可选的扩展ARM内核,大多数的Cortex-A8的有他们,并在iPhone和iPad使用的所有的人的人做的一样好

Though VFP and Neon are optional extensions to the ARM Core, most of the cortex-A8 have them and all of them ones used in the iPhone and iPad do as well.

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

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