Possible Duplicate:
Use of caret symbol( ^ ) in Ruby
So I was playing around with some code and I tried to play around with the power operator. So I thought that perhaps I could use the caret (^) for this purpose, but after using it in:
for i in 0..10
puts "#{i} #{1^i}\n"
end
I got some really funky results
0 - 1
1 - 0
2 - 3
3 - 2
4 - 5
5 - 4
6 - 7
7 - 6
8 - 9
9 - 8
10 - 11
The only pattern I see is -1 on an odd number and +1 on an even number, but then when I try:
for i in 0..10
puts "#{i} #{2^i}\n"
end
i get:
0 - 2
1 - 3
2 - 0
3 - 1
4 - 6
5 - 7
6 - 4
7 - 5
8 - 10
9 - 11
10 - 8
wth! So then I kept going up to 4^i and plotted them, the 1^i & 3^i came out with decent patterns but 2^i & 4^i were just all over the place with no visible patterns (though highly unlikely) with just 11 plotting points, so I've come to you ladies and gents asking you:
What on earth is ^ used for?!