Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ xp_compute math question
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Robert Powell
Australia (367 posts) Bio
|
Date
| Tue 19 Jul 2005 09:15 AM (UTC) |
Message
| could someone explain to me what the >> 2 does in the following fragment.
xp = (xp*3) >> 2; |
Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Tue 19 Jul 2005 08:07 PM (UTC) |
Message
| >> 2 means bitwise shift right by two.
If you have the number 4, which is 100 in binary, then 4 >> 1 is equal to 10 which is 2. 4 >> 2 equals 1 which is 1. 5 in binary is 101, so 5 >> 1 = 2 and 5 >> 2 = 1.
The quick answer is that "x >> 2" is an extremely efficient way to (integer-)divide x by two. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
9,697 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top