Jump to content


Photo

Right Shift Operator


  • Please log in to reply
4 replies to this topic

#1 jana

jana

    GMC Member

  • GMC Member
  • 153 posts

Posted 23 May 2012 - 04:47 PM

Do computations with the right shift operator use a logical or arithmetic shift? I don't
see it documented anywhere, but I was going to guess it's a logical shift.

Edited by jana, 23 May 2012 - 06:02 PM.

  • 0

#2 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 05:07 PM

Do computations with the right shift operator use a logical or arithmetic shift? I don't
see it documented anywhere, but I was going to guess it's a logical shift.

Can you tell us why that is important, I'm more intermediate than advanced.
  • 0

#3 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 5219 posts
  • Version:GM8

Posted 23 May 2012 - 05:38 PM

Arithmetic I think.
If you mean "does it set the carry bit", then the answer is no from what I've seen. ... Seeing as how there's no built-in bitwise rotation function, I don't know how to go about testing it. It's just a simple floor(n/2) shift.

Edit: Sorry, my bad. I forgot about general terms. I haven't tested but that would be easy enough to test. Just take a negative number and apply a right-shift. If it stays negative, it's arithmetic. I'm at work so I can't test just now. But as far as the flooring, I'm pretty sure I saw it floor 3>>1 to 1.

Edited by TheouAegis, 23 May 2012 - 05:46 PM.

  • 0

#4 jana

jana

    GMC Member

  • GMC Member
  • 153 posts

Posted 23 May 2012 - 06:00 PM


Do computations with the right shift operator use a logical or arithmetic shift? I don't
see it documented anywhere, but I was going to guess it's a logical shift.

Can you tell us why that is important, I'm more intermediate than advanced.


It's important, because I'm checking out some code in C++ I might use, and it uses the right shift.

Edited by jana, 23 May 2012 - 06:00 PM.

  • 0

#5 jana

jana

    GMC Member

  • GMC Member
  • 153 posts

Posted 23 May 2012 - 06:01 PM

Arithmetic I think.
If you mean "does it set the carry bit", then the answer is no from what I've seen. ... Seeing as how there's no built-in bitwise rotation function, I don't know how to go about testing it. It's just a simple floor(n/2) shift.

Edit: Sorry, my bad. I forgot about general terms. I haven't tested but that would be easy enough to test. Just take a negative number and apply a right-shift. If it stays negative, it's arithmetic. I'm at work so I can't test just now. But as far as the flooring, I'm pretty sure I saw it floor 3>>1 to 1.


Thank you, you're right, I'll go test it.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users