Negaal
2008-03-15 18:32:01
Well, I came up that they are "Logical shifts", they are easy to understand from wikipedia explanation but when it goes on testing, I fail.
So please someone explain, and some examples where it can be used(compressing several ints, sending them, and then unpacking, true?)?
Edit: Ben knows, thats sure :rolleyes:
Err. Killerdou explained it to me once, but I was too nuub to understand.
ive never used it but i think its bit shifting.
shl : shift Left
shr: shift Right
basically the left/right bit of the integer is taken off and a 0 is put on the opposite side. Idk much, so im sure someone will explain it better, please correct me if im wrong too.
mastaraymond
2008-03-15 19:31:09
An integer is like 01010001110 in bits, okay?
Shl and Shr basicly shifts all these bits to the right or to the left.. Thats all.
From: mastaraymond
An integer is like 01010001110 in bits, okay?
Shl and Shr basicly shifts all these bits to the right or to the left.. Thats all.
im interested now in how you implement this though?
bullzeye95
2008-03-15 19:34:32
Ok, let's look at a binary example. For an example, let's take 1101, which is 13. Shr and shl mean shift bits right, and shift bits left. So if we do shl 1, we're shifting all of those left one place, and we would en up with 11010. If we do shr 1, we're shifting them right one place, and we would end up with 110. Notice how the last 1 vanished. You can lose bits while doing shr. For one more example, 1101 shl 3 would look like 1101000, which is 104.
I hope that helped :)
EDIT: I got pwnt.
mastaraymond
2008-03-15 19:50:59
From: munk
im interested now in how you implement this though?
They are used a lot, if your interested search the tutorial made by Yakmans, called : Bitwise, or something like that.
EDIT:
http://www.srl-forums.com/forum/showthread.php?t=20236&highlight=Bitwise