Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ^ operator do?

Tags:

c#

math

I thought that ^ did that. I expected:

10^0=1
10^1=10
10^2=100

What I'm getting

10^0=10
10^1=11
10^2=8

the actual code is

int value = 10 ^ exp;

replacing exp for 0, 1, and 2 What does the ^ operator do?

like image 716
scott Avatar asked Jul 01 '11 18:07

scott


People also ask

What do you mean by operators?

Definition of operator 1 : one that operates: such as. a : one that operates a machine or device. b : one that operates a business. c : one that performs surgical operations. d : one that deals in stocks or commodities.

What is the need of operators?

Operators are the backbone of any program and they are used for everything from very simple functions like counting to complex algorithms like security encryption. There are several classifications of operators and each of them can have one or more operands, a specific data that is to be manipulated.

What is operator and its uses?

Arithmetic Operators are used to perform mathematical calculations. Assignment Operators are used to assign a value to a property or variable. Assignment Operators can be numeric, date, system, time, or text. Comparison Operators are used to perform comparisons.


1 Answers

Math.Pow(x, y) to get x raised to the power of y. You were doing an XOR. C# operators

like image 189
Coeffect Avatar answered Nov 15 '22 04:11

Coeffect