For example, with primitive, I'll do this
if ( (x >= 6000) && (x <= 20000) )
// do something here
and with NSDecimalNumber, this is what I have
if ( (([x compare:[NSNumber numberWithInt:6000]] == NSOrderedSame) ||
([x compare:[NSNumber numberWithInt:6000]] == NSOrderedDescending))
&& (([x compare:[NSNumber numberWithInt:20000]] == NSOrderedSame) ||
([x compare:[NSNumber numberWithInt:6000]] == NSOrderedAscending)) )
{
// do something here
}
Is there any other ways (easier and more elegant) to this comparison? If I convert the value to primitive, what primitive do I use? I don't want to use CGFloat, float or double, as I'm handling with currency here. Or if I do convert them to those mentioned above, can someone verify / explain about the precision?
if (([x compare:[NSNumber numberWithInt:6000]] != NSOrderedAscending) && ([x compare:[NSNumber numberWithInt:20000]] != NSOrderedDescending))
gives same result. – Blida