## Witchking's Profile User Rating:

Reputation: 63 Whiz
Group:
Active Members
Active Posts:
177 (0.6 per day)
Joined:
17-February 13
Profile Views:
1,277
Last Active:
Nov 19 2013 12:29 PM
Currently:
Offline

### Previous Fields

Country:
FI
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Who Cares
Dream Kudos:
0
Witchking has not set their status

1. #### In Topic: Problem: How to add '^' operator into Infix to Prefix and Post

Posted 1 Oct 2013

^ is XOR. If you want power use Math.pow.
2. #### In Topic: Difference between object/Object and string/String

Posted 27 Sep 2013

You can also use using to declare your own aliases, like so
```using strb = System.Text.StringBuilder;
```
3. #### In Topic: Reversing an Array - Use Cases

Posted 24 Sep 2013

jakobt, on 24 September 2013 - 03:13 PM, said:

I can't say that XORs are my greatest strength, what is the idea behind being able to use them to swap two values in place? Do you do a comparison at the binary level and change the values of the bits?

The XOR swap algorithm is
```x = x ⊕ y
y = x ⊕ y
x = x ⊕ y
```
Now to break it down, we start with x0 and y0. Then

x1 = x0 ⊕ y0
y1 = x1 ⊕ y0
x2 = x1 ⊕ y1

Notice that y1 is equal to (x0 ⊕ y0) ⊕ y0, and because of the XOR's associativity we can write this as x0 ⊕ (y0 ⊕ y0). We also know that a ⊕ a = 0 and a ⊕ 0 = a so in fact y1 = x0.

Now x2 is equal to (x0 ⊕ y0) ⊕ x0) because y1 = x0. Using the same associativity as before, we find that x2 can be written as y0 ⊕ (x0 ⊕ x0), which in turn we can see is equal to y0, and so we have swapped x0 and y0.

Now, while this works for any data that you can XOR, i would recommend simply using a temporary variable and doing all your swapping like that, especially if you don't quite understand the XOR swap, in order to improve the readability and maintainability of your code. Historically it was useful to use the XOR swap instead of a temporary variable to conserve memory, but that is no longer needed today.
4. #### In Topic: Quadratic Equation...

Posted 24 Sep 2013

Why on earth would you pass in a boolean for the discriminant in the constructor when you can calculate it as b2 - 4ac?
5. #### In Topic: Checkerboard

Posted 23 Sep 2013

Curtis Rutland, on 23 September 2013 - 10:05 PM, said:

And Adam is correct, but it's no more efficient (you're going to run 64 iterations either way), so either way you do it is "right".

It may not be more efficient, but it is more fun.

### My Information

Member Title:
Age:
19 years old
Birthday:
March 1, 1994
Gender:
Location:
Finland
Programming Languages:
C#

E-mail:
Private