Hi,
Could someone explain how using a binary operation, in this case AND is useful:
If I take the binary for 11 and the binary for 13, and AND the results:
1101 (11)
1011 (13)
-----
1001 (9) - Is this TRUE or FALSE?
What exactly does it acheive? I'm asking because a snippet of code I've been given shows binary operations, basically, a number is taken, if the number is negative it is AND'ed with 128 and converted to ASCII Charater equivilent.
When the character string is to be converted back into a number, the string's ASCII Code equivilent is AND'ed with 128, and this is used to set a variable so that we know to make the number negative. I just don't understand how this is working. As I see it (obviously wrongly), if you AND two numbers, unless they are the identical (in binary) the result should be false?
Any help appericated
Thanks
Could someone explain how using a binary operation, in this case AND is useful:
If I take the binary for 11 and the binary for 13, and AND the results:
1101 (11)
1011 (13)
-----
1001 (9) - Is this TRUE or FALSE?
What exactly does it acheive? I'm asking because a snippet of code I've been given shows binary operations, basically, a number is taken, if the number is negative it is AND'ed with 128 and converted to ASCII Charater equivilent.
When the character string is to be converted back into a number, the string's ASCII Code equivilent is AND'ed with 128, and this is used to set a variable so that we know to make the number negative. I just don't understand how this is working. As I see it (obviously wrongly), if you AND two numbers, unless they are the identical (in binary) the result should be false?
Any help appericated
Thanks