Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

bitwise comparison & IF condition

bitwise

Best Answer Nishant, 24 February 2014 - 06:50 AM

okay so the solution was to compare the mask with the result like>> if ((this_led_color & mask) == mask) and its done!

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 Nishant

Nishant

    New Member

  • Members
  • Pip
  • 3 posts

Posted 24 February 2014 - 06:32 AM

How to tackle with such pure C implementations in C#:

if ((this_led_color & mask))       SDI.Write(true);   else       SDI.Write(false);

its shows me the error: Error 17 Cannot implicitly convert type 'long' to 'bool'


"Real Men can Accomplish Anything"
nishant@winacro.com
www.winacro.com

#2 Nishant

Nishant

    New Member

  • Members
  • Pip
  • 3 posts

Posted 24 February 2014 - 06:50 AM   Best Answer

okay so the solution was to compare the mask with the result like>> if ((this_led_color & mask) == mask) and its done!


"Real Men can Accomplish Anything"
nishant@winacro.com
www.winacro.com

#3 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 24 February 2014 - 09:45 PM

That makes it compile but it's not quite the same thing, I'd say it translates into this:
if ((this_led_color & mask) != 0)       SDI.Write(true);else       SDI.Write(false);
Checking for equality to mask is no longer the same when mask has other than a single bit set.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.