Welcome Guest. Please Login or Register. Apr 5th, 2018, 10:55pm
ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018. Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.
If you require a dump of the post on your message board, please come to the support board and request it.
How do you the right shift operator ">>" a few examples would help
The informal syntax is:
Code:
result = number >> shift
Where number is a numeric value (assumed integer) and shift is the number of bits by which you want to shift it.
So for example if you do:
Code:
PRINT %10101010 >> 3
the result will be %10101, or 21 in decimal.
For positive numbers the right-shift operator is equivalent to dividing by the equivalent power-of-two, so for example:
number >> 1 gives the same result as number DIV 2 number >> 2 gives the same result as number DIV 4 number >> 3 gives the same result as number DIV 8
But that equivalence doesn't necessarily apply for negative numbers.
Google will find you many web pages describing the shift operators and their uses, for example here (strictly it is talking about Java but the BBC BASIC shifts work just the same):