Jump to content
OMRON Forums

bitwise operator &


JeffB

Recommended Posts

Will the code below work such that even_number is false if count is odd, true if count is even? Any issue with count actually being a floating point number instead of an integer? Seems not working in the field (count is always 0) but I don't have the hardware at hand to test.

global count
global even_number

count = 2;

if ((count & $1) == 0) even_number = 1 else even_number = 0

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...