Predefined function for minimum

Possible duplicate:
Is there a convenient feature in objective-c / coca-touch to find the lowest number?

#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int a=10,b=5,c; c=min(a,b); NSLog(@"min:%d",c); [pool drain]; return 0; } 

I have to calculate the minimum value of two numbers. We can use if (a> b) to find out the minimum value. But is there any predefined function to calculate the minimum of two numbers.

+6
source share
1 answer

It has already been discussed. Objective-C includes a MIN (a, b) macro that should suit your needs.

+17
source

Source: https://habr.com/ru/post/889948/


All Articles