In PSET4 Edges Filter problem you are supposed to calculate Gx ^ 2. But the operator ^ in C does not seem to mean raising in a power. For Gx = -9 it returns Gx ^ 2 = -11 and so on. Turned out ^ is XOR operator. I ended up using Gx * Gx but I wonder if there is a proper operator.

I'm also confused about the use of ^ 2 in the text of the problem on CS50. It was framed as a code sample, but ended up not working as one due to the ambiguity of ^ symbol. Is that a typo?


This is not to be taken literally, the circumflex accent notation ^ is a common way of representing power, and it is indeed a bitwise operator in C. For power we must use the function pow (), it is simple to use and You can search for examples in google.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .