diff --git a/cv3/program.c b/cv3/program.c index 0ee4298..ee0b55a 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -33,13 +33,13 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){ switch(buffer[currentlyInBuffer][0]){ case '+': - temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) + atof(buffer[currentlyInBuffer-1]))*100)/100; + temporaryDecimal = round(atof(buffer[currentlyInBuffer-2])*100)/100 + round(atof(buffer[currentlyInBuffer-1])*100)/100; break; case '-': - temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) - atof(buffer[currentlyInBuffer-1]))*100)/100; + temporaryDecimal = round(atof(buffer[currentlyInBuffer-2])*100)/100 - round(atof(buffer[currentlyInBuffer-1])*100)/100; break; case '*': - temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) * atof(buffer[currentlyInBuffer-1]))*100)/100; + temporaryDecimal = round(atof(buffer[currentlyInBuffer-2])*100)/100 * round(atof(buffer[currentlyInBuffer-1])*100)/100; break; case '/': if(atof(buffer[currentlyInBuffer-1]) == 0.0) { @@ -47,7 +47,7 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){ return false; } else - temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) / atof(buffer[currentlyInBuffer-1]))*100)/100; + temporaryDecimal = round(atof(buffer[currentlyInBuffer-2])*100)/100 / round(atof(buffer[currentlyInBuffer-1])*100)/100; } for(int i = currentlyInBuffer-2; currentlyInBuffer > i; currentlyInBuffer--)