# CCSprite x and y comparison

I have 2 CCSprites and I want to tell if their x and y are equal I tried this:

if(sam.position.x == tom.position.x && sam.position.y == tom.position.y){
NSLog(@"Hooray!");
}


Although I do not think this is the right way to do this. Could anyone help me?

Thanks.

ALSO The CCSprites are named sam and tom.

if(fabsf(sam.position.x - tom.position.x) < 0.5f && fabsf(sam.position.y - tom.position.y) < 0.5f)

Of course you can change the "threshold/accuracy" by increasing or decreasing the 0.5f value.