Изменил(а) на 'cv3/program.c'

This commit is contained in:
Oleksandr Hryshchenko 2021-10-22 12:09:25 +00:00
parent 054ef15374
commit c388fee424

View File

@ -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--)