I read that the ^
operator is the logical xor operator in c#, but i also thought it was the "power of" operator. Can someone clear this up for me?
views:
1443answers:
1
+16
A:
It is not the power of operator of C# since there is no such operator in C#. It is just the XOR operator.
For "power of", use Math.Pow.
As you can see from this page on the C# Operators, ^
is listed under the "Logical (boolean and bitwise)" category, which means it can both handle boolean values, and binary values (for bitwise XOR).
Lasse V. Karlsen
2009-10-02 07:32:51
hmm, then wherever i was using that operator as "power of" i'll have to fix at some point...
RCIX
2009-10-02 07:36:55
Just to add: The PowerOf Function in C# is Math.Pow. http://msdn.microsoft.com/en-us/library/system.math.pow.aspx
Michael Stum
2009-10-02 07:37:18
@RCIX: Didn't you notice any incorrect results when you were attempting to use `^` as the power-of operator?
LukeH
2009-10-02 08:27:32
`^` is the "power of" operator in VB.NET.
Christian Hayter
2009-11-01 14:07:39