fixnuty floating point presnost

This commit is contained in:
Aleš Novysedlák 2025-03-10 13:33:36 +01:00
parent 1b903cb9fa
commit ab1db7e617

View File

@ -65,7 +65,7 @@ int main() {
total = divided(total, atof(equation[i])); total = divided(total, atof(equation[i]));
break; break;
case '=': case '=':
if (total == atof(equation[i])) { /*if (total == atof(equation[i]))*/if (fabs(total - atof(equation[i])) < 1e-6) {
strcpy(output[output_length], "OK"); strcpy(output[output_length], "OK");
output_length++; output_length++;
} }
@ -88,7 +88,7 @@ int main() {
sign = !sign; sign = !sign;
} }
memset(equation, 0, sizeof(equation)); memset(equation, 0, sizeof(equation));
//printf("%s\n",out); printf("%f", total);
} }
for (int i=0; i<output_length; i++) { for (int i=0; i<output_length; i++) {