How do I create the following method?
- I have tried to use modf(n, 1) or modf(n, 2) but those both return an error of "Passing argument 2 of modf makes pointer from integer without a cast.
Heres the method:
(BOOL) numberHasDecimal: (long double) n {
if (?????) // has decimal, like 16.300000 or 6453.353259
return YES;
else
return NO; // has no decimal, like 58.000000 or 9274.000000
}
Keep in mind that floating point values are internally rounded in counter-intuitive ways, so a number may have a very small fractional component and still appear integral when passed through
fmodl()
.Also note that Apple's implementation of Objective-C is broken when handling
long double
values, and may manifest difficult-to-track errors when you use them.