Search code examples
objective-cnumeric-limits

objective-c equivalent to c++ numeric_limits::max()


I've gotten used to utilizing the numeric_limits part of the C++ STL for initializing numeric types (int,float, etc.) to their largest possible value. I.e. int i=numeric_limits::max()

Is there an equivalent to this in objective-c? I've seen using INT_MAX and FLT_MAX in google searches, but it seems like there should be a better way.


Solution

  • There is:

    NSIntegerMax, NSIntegerMin, CGFLOAT_MAX etc.

    These are sufficient for getting the numeric limits.