Metaquotes Language 5-Typecasting Question

 

Hi 

I'd just like to ask what this code means

int session =B'111111111';

int bit=1;

bool workinghour = (session&bit)==bit;

to be more precise, what does the (session&bit) part of the code do?

 
RoboAlias:

Hi 

I'd just like to ask what this code means

int session =B'111111111';

int bit=1;

bool workinghour = (session&bit)==bit;

to be more precise, what does the (session&bit) part of the code do?

session is a binary representation of the number 255 ie: 8 bits

bit is not a bit but an integer number in this case 1

workinghour is true or false depending on the result session AND bit

in this case any number upto 255 would return true as all bits are set to 1