View Full Version : Right Shift operator

01-18-2007, 01:46 AM
The example on page 72 of the basic stamp manual version 2 for the right shift operator is:

'ˇ {$stamp BS2}
valueˇ var word
ldx var byte
value = %111111111111111
for ldx = 1 to 16
ˇ debug bin ? value >> ldx

This works correctly. Now the problem:
IfˇI make the statement:

value >> 3ˇˇ

or, say
value >> ldx
I get a compilation error, stating that an = was expected after the variable "value".
Please help! Thanks

01-18-2007, 02:15 AM
Hi traction, if you write it as value=value>>ldx that should work or create another word variable called new_value and write it as new_value=value>>ldx that will work too.

Jeff T.

Mike Green
01-18-2007, 02:16 AM
The shift operator ">>" is just that, a binary operator that produces a result.ˇ It's not a statement which PBasic is expecting, so you do need to do something with the value produced for PBasic to "be happy".ˇ You can use an assignment if what you really mean is "x = x >> 3".

01-18-2007, 02:31 AM
Thanks for the quick replies!!! Have a great day Mike and Unsoundcode, Gary