0

This is something wired happening in my program, hope you can help me I m trying to compare array elements inside a if condition, This works when comparing value is zero.

if((y[5]<0) && (y[4]>0)){
//do something
} 

But when i try to compare the value with 20, it fails, if condition is not working!

if((y[5]<20) && (y[4]>20)){
    //do something
    } 

Since my array contains floating numbers, i tried this too, but it too fails,if condition is not working!

if((y[5]<20.00f) && (y[4]>20.00f)){
        //do something
        } 

Any idea why this happens? It drives me crazy! :( :( :(

4

1 回答 1

2

你应该试试 :

  if(([[y objectAtIndex:5] intValue]<20) && ([[y objectAtIndex:5] intValue]>20))
  {
    //do something
  } 
于 2012-06-04T09:47:56.710 回答