How do I set a UInt32 to it's maximum value How do I set a UInt32 to it's maximum value ios ios

How do I set a UInt32 to it's maximum value


There's a macro UINT32_MAX defined in stdint.h which you can use

#include <stdint.h>uint32_t max = UINT32_MAX;

More about the relevant header <stdint.h>:

http://pubs.opengroup.org/onlinepubs/009695299/basedefs/stdint.h.html


The maximum value for UInt32 is 0xFFFFFFFF (or 4294967295 in decimal).

sizeof(UInt32) would not return the maximum value; it would return 4, the size in bytes of a 32 bit unsigned integer.


Just set the max using standard hexadecimal notation and then check it against whatever you need. 32-bits is 8 hexadecimals bytes, so it'd be like this:

let myMax: UInt32 = 0xFFFFFFFFif myOtherNumber > myMax {    // resolve problem}