Bitwise Operators

Posts 112 of 12 · Page 1 of 1
Bitwise Operators
this piece of my tutorial i don't understand.

In general, &, |, ^, and ~ apply their operations directly to each bit in a value individually. For this reason, bitwise operations are not usually used in conditional statements the way the relational and logical operators are. For example, if x equals 7, then x && 8 evaluates to true, whereas x & 8 evaluates to false.
i think i understand the false

this is what i think that it means

0111 = 7
1000 = 8
____&
0000 = false
Quote Originally Posted by lalakijilp View Post
this piece of my tutorial i don't understand.

i think i understand the false

this is what i think that it means
Hey lala your exactly right. Sorry I wasn't on nine hours ago to tell you, but yeh that is exactly right! good work! There's all sorts of things you can do with bitwise operations. Sometimes I like to use bitwise comparisons instead of boolean just for fun
Quote Originally Posted by why06 View Post
Hey lala your exactly right. Sorry I wasn't on nine hours ago to tell you, but yeh that is exactly right! good work! There's all sorts of things you can do with bitwise operations. Sometimes I like to use bitwise comparisons instead of boolean just for fun
but why is this true?
then x && 8 evaluates to true
you're doing basically a logic 7 AND 8 operator
since 7 is not 0/FALSE thus is 'TRUE' and 8 is not 0/FALSE thus is 'TRUE'
you end up with TRUE AND TRUE = TRUE
Quote Originally Posted by B1ackAnge1 View Post
you're doing basically a logic 7 AND 8 operator
since 7 is not 0/FALSE thus is 'TRUE' and 8 is not 0/FALSE thus is 'TRUE'

you end up with TRUE AND TRUE = TRUE


this part of your explaination i dont understand.


edit: wait i think i understand. i thougt you were saying zero divided by false, but now i see you were saying zero == false

so basicly && is

nonzero && nonzero = true
zero && zero = false
nonzero && zero = false
edit: Sorry yeah 0 == false Sounds like you got it - just imagine like you're working with 1 bit and the value is either TRUE (== 1 or 'not 0') or False(==0)


Ok
& = BitWise AND, while on the flipside
&& = LOGIC AND

You understand BITWISE AND as you described above
you 'AND' every bit in the value A with the matching bit in Value B
What do we know about TRUE & False? False is usually '0' and TRUE is usually 1 (or more) or expressed in 'logic': True is NOT 0

Code:
0111 = 7
1000 = 8
____&
0000 = false 

or say
1110 = 14
0100 = 4
_________ &
0100 = 4  ; this is NOT 0 (False) so it has to be 'True'
Keeping mind that 0==False and TRUE is anything that is NOT 0
The logic comparison you wrote is basically saying:
7 AND 8:
is 7 the same as 0(FALSE)? No, so that operand translates into 'TRUE'
is 8 the same as 0(FALSE)? No, So this operand also is 'TRUE'
So you end up with : TRUE and TRUE (or 1 and 1 if you will) which results in TRUE (1)
Code:
01000010001100010110000101100011011010110100000101101110011001110110010100110001001000000110100101110011001000000111010001101000011001010010000001100100011011110110110101101001011011100110000101110100011010010110111101101110001000000110011101110101011110010010000001100110011100100110111101101101001000000111010001101000011001010010000001101100011001010110010101110100001000000111011101101111011100100110110001100100001000010010000001101000011001010010000001110011011000010111011001100101011100110010000001101111011101010111001000100000011100110110111101110010011100100111100100100000011000010111001101110011011001010111001100100000011001100111001001101111011011010010000001100011011011110110110101110000011010010110110001100101011100100010000001100101011100100111001001101111011100100111001100100000011000010110111001100100001000000110100101110011001000000111010001101000011001010010000001101101011000010111001101110100011001010111001000100000011011110110011000100000011101000110100001100101001000000111010101101110011010010111011001100101011100100111001101100101001000000011101100101001
translate me to text
you making some kind of "he-man "joke with the master of the universe thing? lol :P
Quote Originally Posted by B1ackAnge1 View Post
you making some kind of "he-man "joke with the master of the universe thing? lol :P
didn't there was a keyboard with only two buttons on it in "the old days"?

a 1 and a 0
Quote Originally Posted by lalakijilp View Post


didn't there was a keyboard with only two buttons on it in "the old days"?

a 1 and a 0
Yeh it was called a light switch...
How about a 3 key keyboard?
Lol. Those are the only keys you need I guess. haha!
Posts 112 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?