简体   繁体   English

Objective-c从两个NSIntegers中获得最大收益

[英]Objective-c get greatest from two NSIntegers

Now i am getting greatest NSInteger by suing MAX() example 现在,我通过使用MAX()示例获得了最NSInteger

NSInteger x = 10;
NSInteger y = 15;
NSInteger max = MAX(x,y);

But i am interested in why this function only used for int values mainly? 但是我对为什么此函数主要仅用于int值感兴趣? And if it is correct to use MAX() for NSIntegers? 如果对NSIntegers使用MAX()是否正确?

The MAX() macro can be used for any two types which can be compared using < (less-than). MAX()宏可用于任何两种类型,可以使用< (小于)进行比较。 For C numeric types, the usual rules involving promotion and conversion of type will apply. 对于C数字类型,将适用涉及类型提升和转换的常规规则。

Short answer: MAX() works fine for NSIntegers. 简短的答案: MAX()对于NSIntegers很好用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM