Shop OBEX P1 Docs P2 Docs Learn Events
Right Shift operator — Parallax Forums

Right Shift operator

tractiontraction Posts: 2
edited 2007-01-17 19:31 in BASIC Stamp
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
next

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
·

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-01-17 19:15
    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 GreenMike Green Posts: 23,101
    edited 2007-01-17 19:16
    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".
    ·
  • tractiontraction Posts: 2
    edited 2007-01-17 19:31
    Thanks for the quick replies!!! Have a great day Mike and Unsoundcode, Gary
Sign In or Register to comment.