Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator '^' cannot be applied to operands of type 'double' and 'double'

Tags:

c#

I have this code:

private void t_Tick(object source, EventArgs e)
    {
        double anInteger;
        anInteger = Convert.ToDouble(label1.Text);
        anInteger = double.Parse(label1.Text);
        double val1;
        double val2;
        double answer;
        double previous_val;
        previous_val = Convert.ToDouble(label1.Text);
        previous_val = double.Parse(label1.Text);
        val1 = anInteger;
        val2 = ((((((previous_val ^ 1.001)) / 24) - ((previous_val / 24) / 60)) / 10));
        answer = val1 + val2;


        label1.Text = answer.ToString();
    }

I am getting the error "Operator '^' cannot be applied to operands of type 'double' and 'double'" at the line:

val2 = ((((((previous_val ^ 1.001)) / 24) - ((previous_val / 24) / 60)) / 10));

Does anyone have any solutions?

like image 856
Vlad Avatar asked Oct 02 '11 00:10

Vlad


2 Answers

Math.Pow(previous_val, 1.001);

will solve your problem. this is the way how to use powers with double.

like image 105
icaptan Avatar answered Jan 10 '23 18:01

icaptan


^ is bitwise operator XOR. It makes no sense on double type.

What was your intent?

like image 35
Al Kepp Avatar answered Jan 10 '23 17:01

Al Kepp