I have a string that I convert to a double like this:
double d = [string doubleValue];
The documentation for doubleValue
tells
Probably not necessary for this very simple use case, but here is an example of how you would account for the potential discrepancy if you were trying check if a number is equal to -1:
#include
#include
int main(void) {
float sales = -1;
// basically if sales == -1
if (fabs(1 + sales) < FLT_EPSILON) {
return 0;
}
}