If I type 0.01 or 0.02 the the program just exits immediately. What do I do?
#include
char line[100];
float amount;
int main()
{
printf(\"E
I think we could scale for a factor and make a relative comparison like this:
#define EPSILON (0.000001)
if (fabs(a - b) <= EPSILON * fmax(fabs(a), fabs(b))) {
}
which is more robust than an absolute comparison:
if (fabs(a - b) <= EPSILON ) {
// ...
}
which maybe scale dependent. By the way having the optimum scale depends also from the function, we shouldn't use the same formula for a log and for a sin.