You are reading the value from display1
twice, you forgot to change the reading of number2
to display2
.
Replace:
number2 = Double.valueOf(display1.getText().toString());
with
number2 = Double.valueOf(display2.getText().toString());
Your function would end up being:
if(minu){
number1 = Double.valueOf(display1.getText().toString());
number2 = Double.valueOf(display2.getText().toString());
display1.setText("");
display2.setText("");
displaySymbol.setText("");
answer = number1 - number2;
display1.setText(Double.toString(answer));
}
0
solved Android: Division and subtraction always equal 1.0