1

In some cases it can be important to select the correct floating point type for your application, and it seems that on ios/osx you are pushed in the direction of using CGFloat.

CGFloat is meant to be the native floating point type, but I can't find a good summary of which device is 32bit or 64bit (and I would worry that the head-line designation might be for the integer unit or the address bus which might be different from the FP unit).

Furthermore, I assume all of the hardware supports double FP anyway, albeit at lower performance than the native 64 bit units.

Presumably, the O/S is irrelevant as this applies only to the use of the address space (but correct me if I am wrong).

rghome
  • 8,529
  • 8
  • 43
  • 62

1 Answers1

1

Support for the 64bit architecture was introduced for the first time in Apple's A7 chip, which means that the first device to support 64bit was the iPhone 5S. The first iOS version to support it was iOS 7.

That said, I don't really understand why does it matter which device/OS is it. Your code should just handle 32bit/64bit properly. CGFloat is 4 bytes on 32bit systems and 8 bytes on 64bit systems, that's the only consideration.

Artal
  • 8,933
  • 2
  • 27
  • 30
  • In other languages, the developer makes the choice of singe or double FP based on precision requirements, but here Apple kind-of takes it out of your hands by default. Some times you might want to take that decision back, so it would be good to know what is going on, and to clear up some of the confusion. For example, you imply that iOS 7 was the first O/S with 64 bit floats, but is that the case or was it the first O/S with a 64 bit address space? – rghome Jun 06 '15 at 19:18
  • iOS 7 was the first version of iOS with 64bit address space and therefore the first with 64bit floats. If you want more control just use "float" and "double" which is consistent in 32bit/64bit systems (unlike CGFloat). Otherwise, i'm not sure I completely understand your question. – Artal Jun 06 '15 at 19:25
  • 2
    There word "therefore" in your comment is not correct. There is not necessarily a connection between the size of the addresses and the size of the floating point unit. – rghome Jun 06 '15 at 19:30
  • Maybe not necessarily true, but in the case of iOS it is true (to the best of my knowledge). If you know otherwise, please share. – Artal Jun 06 '15 at 19:33
  • No - I don't know. That is why I asked the question :-). Thanks for your input. – rghome Jun 06 '15 at 19:34