Aran Mulholland Aran Mulholland - 1 year ago 57
iOS Question

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

  1. What is the maximum value for a UInt32?

  2. Is there a way I can use the sizeof operator to get the maximum value (as it is unsigned)? So I don't end up with #defines or magic numbers in my code.

Answer Source

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>: