6/26/2009

"^" in C++ means bitsize exclusive OR

The ^ (bitwise exclusive OR) operator compares each bit of its first operand
to the corresponding bit of the second operand. If both bits are 1's or both
bits are 0's, the corresponding bit of the result is set to 0. Otherwise, this
operator sets the corresponding result bit to 1.

The following example shows the values of a, b, and the result of a ^ b
represented as 32-bit binary numbers:

bit pattern of a 00000000000000000000000001011100

bit pattern of b 00000000000000000000000000101110

bit pattern of a^b 00000000000000000000000001110010

so it can not be used in power function,
you need to use

pow (7,3)

to get 7^3;

没有评论: