BitRead Function

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
outlawstc
Posts: 32
Joined: Tue Oct 15, 2013 6:14 pm
Has thanked: 12 times
Been thanked: 9 times
Contact:

BitRead Function

Post by outlawstc »

Arduinos program has A bitread function..
How do you perform this task in flowcode?

http://arduino.cc/en/Reference/BitRead
"If your having code problems I feel bad for you son... I got 99 problems but a glitch ain't one"

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BitRead Function

Post by medelec35 »

Martin

User avatar
outlawstc
Posts: 32
Joined: Tue Oct 15, 2013 6:14 pm
Has thanked: 12 times
Been thanked: 9 times
Contact:

Re: BitRead Function

Post by outlawstc »

I brought this over to there topic just to make it simple on others who may seek the same answer.. Thanks again medelec35
medelec35 wrote:For my 2 pence worth.
How I check is a bit is set or clear:
(Variable & (1 << bit)) <> 0 // to Check if bit of variable is set
or
(Variable & (1 << bit)) = 0 // to Check if bit of variable is Clear

So if you want to see if bit 2 is Clear:
If (Variable & (1 << 2)) = 0 then it's clear

If you want to see if bit 2 is Set:
If (Variable & (1 << 2)) <> 0 then it's set


Also if you want to set a bit:
Variable = Variable |(1<<bit)

To clear a bit:
Variable = Variables &~(1<<bit)


Martin
"If your having code problems I feel bad for you son... I got 99 problems but a glitch ain't one"

Post Reply