File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Binary AND Operator

 
celine mcgowan
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I made a post a while ago called Manipulating Binary Numbers. Basically what i am trying to do is make an LED. I need to read a Byte of input & where there is a 0 in the binary input, the corresponding 'segment' of the LED is lit.
I received the following in reply to my last post:

Where 'charWord' is declared as:

But, when i try to run this i get the following error from the compiler:
"operator & cannot be applied to byte,boolean"
Does anyone know how i can apply the binary AND operator in Java?
Thanks & Regards,
Celine
 
Eddie Vanda
Ranch Hand
Posts: 281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Celine,

This may be a precedence problem. The whole if result should be boolean, so use brackets to force the "and" action first.

Not sure about your logic, though. Normally your byte would be progressively tested against a rotating bit set in a mask.
Ed
Fighting the trend for signature blocks . . . . .
 
Vicken Karaoghlanian
Ranch Hand
Posts: 522
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The '00010000b' is not a valid identifier.
 
celine mcgowan
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
I changed the brackets & it works perfectly. Also, i set up variables for the bytes i needed to compare my word to - 0000001b etc. were not valid but 'byte one = 1;' is very valid!
The guy that replied to the last post was totally on the right track. This is perfect for what i need. You are all lifesavers! Thank you so much!
Best Regards,
Celine
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic