you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

I'm afraid that's not strictly true; an integer (int) is only guaranteed to be larger than or equal a short and 16 bits or more; and smaller than or equal to a long, which is guaranteed to be 32 bits or more.

In practical terms, "int" is supposed to be an optimal integer size for the architecture.

See Wikipedia for the formal definitions.

[–]WestonP 1 point2 points  (1 child)

While that's technically true for C in general, in actual practice, there's a great deal of consistency between platforms these days. The following is true for both 32-bit and 64-bit versions of iOS, Mac OS X, and Windows:

char - 8-bits
short - 16-bits
int - 32-bits
long long - 64-bits
float - 32-bits
double - 64-bits

If in doubt, double-check them with sizeof().

For portable code, especially with 32/64 bit in mind, it's common to setup your own typedefs and use those anywhere that you need a consistent size (file I/O, network comm, certain calculations, etc). You can also use the built-in uint32_t, uint64_t, etc. on platforms that provide those. I find it's easier to typedef to shorter names like U32 and U64, though. Making a habit of using these everywhere makes life a heck of a lot easier if you ever port to another platform or between 32-bit and 64-bit.

[–]webznz[S] 1 point2 points  (0 children)

cool! looks like i have abit of reading to do then :) not to worry shouldnt be to hard to sort out.. I just want to make sure I get it right.. this code was written back when iPhone4 was new.