I am making a calculator on C#.
I have to use float because, when I divide numbers, I get an answer less than 0.
but, I want the calculator to begin the new calculation with the answer i already got, So i wrote:
a = Convert.ToInt64(answer);
but, it doesn’t help, it converts the answer to int64 too.
I think, I will be able to do with pointers, but I don’t know how.
So how can I copy the value of answer to ‘a’ (the Input), without converting answer?
Int64 a; //1st Input
Int64 b; //2nd Input
float answer;
char d;
bool pressed;
private void button11_Click(object sender, EventArgs e)
{
if (d == '+') answer = a + b;
if (d == '-') answer = a - b;
if (d == '*') answer = a * b;
if (d == '/') answer = a / b;
textBox1.Text = a.ToString() + d + b.ToString() + '=' +answer.ToString();
a = Convert.ToInt64(answer);
b = 0;
}
sorry, for the lack of the whole source code, if anybody want’s me to add them too just tell me 🙂
Couple of observations that may help: