Exponents in Vexcode Pro V5 Text?

I am attempting to use the Laws of Cosines, but I am reaching the issue that Vexcode doesn’t seem to know how to do exponents. I am using the standard x^2 format, which is what I would expect, with x being defined as a double. However, it highlights the circumflex and outputs the error “Invalid operands to binary expression (‘double’ and ‘double’)”

For some matters it does not matter, as x^2 is the same as xx. However, I can’t figure out how to do operations such as square roots. Thank you.

lookup the “pow” function.
^ is binary XOR operator in the C language

7 Likes

So it could look something like
c = pow ((2*(pow (r,2))-(2*(pow (r,2))*(cos (θD)))), 0.5);
if the goal was
c = ((2r^2 - (2r^2)cos(θD))^0.5

Also, thank you for that, I didn’t know how to get to the include for math.

sure, but for that equation you could simplify it.
pow(r, 2) is the same as r*r
pow(x,0.5) is the same as sqrt(x)

7 Likes