Chinaunix首页 | 论坛 | 博客
  • 博客访问: 871740
  • 博文数量: 322
  • 博客积分: 6688
  • 博客等级: 准将
  • 技术积分: 3626
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-19 11:26
文章分类

全部博文(322)

文章存档

2013年(5)

2012年(66)

2011年(87)

2010年(164)

分类: LINUX

2012-04-16 17:06:08

+ (CGFloat) Math_max:(id)firstObject, ...;

{

id eachObject;

va_list argumentList; 

CGFloat max = [firstObject floatValue];

if (firstObject)                     

{                                

va_start(argumentList, firstObject);          // Start scanning for arguments after firstObject.

        eachObject = va_arg(argumentList, id);

while (eachObject) // As many times as we can get an argument of type "id"

{

            if ([eachObject floatValue]>max) {

max = [eachObject floatValue];

}

            eachObject = va_arg(argumentList, id);

        }

va_end(argumentList);

}

return max;

}


+ (CGFloat) Math_min:(id)firstObject, ...;

{

id eachObject;

va_list argumentList; 

CGFloat min = [firstObject floatValue];

if (firstObject)                     

{                                

va_start(argumentList, firstObject);          // Start scanning for arguments after firstObject.

        eachObject = va_arg(argumentList, id);

while (eachObject) // As many times as we can get an argument of type "id"

{

            if ([eachObject floatValue]

min = [eachObject floatValue];

}

            eachObject = va_arg(argumentList, id);

        }

va_end(argumentList);

}

return min;

}



用法

maxHighPrice = [NPUtils Math_max:[NSNumber numberWithFloat:maxHighPrice],

[kline objectAtIndex:2],

[arrayMainIndicator objectAtIndex:1],

[arrayMainIndicator objectAtIndex:2],

[arrayMainIndicator objectAtIndex:3],

[arrayMainIndicator objectAtIndex:4],

nil];


阅读(658) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~