I'm dealing with an NSMutableArray of NSNumber and I ran into a weird bug. The [NSNumber doubleValue] (construct with double 0) seems to not to be equals to 0.0.
The bug appears in the simpliest function ever : the max function.
- (double) maxValY{
double max = DBL_MIN;
for (NSNumber *doubleNumber in arrayNumbers) {
if (max<[doubleNumber doubleValue]){
max = [doubleNumber doubleValue];
}
}
NSLog(@"max %f",max);
if(max <=0.0){
NSLog(@"max is equal to 0");
return 1;
}else{
NSLog(@"max is not equal to 0");
}
return max;
}
The console prints :
2013-01-02 11:27:56.208 myApp[1920:c07] max 0.000000
2013-01-02 11:27:56.210 myApp[1920:c07] max is not equal to 0