views:

1694

answers:

3

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

Is this true? Evidence?

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

+4  A: 

The ARM1176JZF-S manual says that it supports double precision floating point numbers. You should be in good shape. Here's a link to the PDF documentation. Later iPhones are Cortex chips, and certainly shouldn't be less capable.

Carl Norum
+19  A: 

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.

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

Stephen Canon
I'm curious to know where you got the info.
Ben Alpert
@Ben: perhaps he just knew it, but if you check my post, the links provide exactly that information and Google returns many more hits about this subject.
Abel
The architecture reference manuals (available free from ARM in this case), a disassembler (otool) and carefully written timing loops suffice to get this information about pretty much any architecture.
Stephen Canon
+5  A: 

This slide show gives insight in why there isn't good floating point and why there is (the vector floating point unit). Apparently, it is important you check the "thumb mode" which influences whether or not floating point support is on. This is not always an improvement. It shows how to find the right instructions in the assembly code.

It also depends on what version of the phone you want to run your code. The most recent one seems "more capable" in doing floating point math.

EDIT: here's an interesting read on floating point optimizations on the ARM with VFP and NEON SSE.

Abel