Results 1 to 12 of 12
  1. #1
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah

    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

  2. #2
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    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

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  3. #3
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah
    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

  4. #4
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    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

  5. #5
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah
    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
    Last edited by lalakijilp; 11-02-2009 at 10:17 AM.

  6. #6
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    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)

  7. The Following 2 Users Say Thank You to B1ackAnge1 For This Useful Post:

    Hell_Demon (11-02-2009),lalakijilp (11-02-2009)

  8. #7
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Code:
    01000010001100010110000101100011011010110100000101101110011001110110010100110001001000000110100101110011001000000111010001101000011001010010000001100100011011110110110101101001011011100110000101110100011010010110111101101110001000000110011101110101011110010010000001100110011100100110111101101101001000000111010001101000011001010010000001101100011001010110010101110100001000000111011101101111011100100110110001100100001000010010000001101000011001010010000001110011011000010111011001100101011100110010000001101111011101010111001000100000011100110110111101110010011100100111100100100000011000010111001101110011011001010111001100100000011001100111001001101111011011010010000001100011011011110110110101110000011010010110110001100101011100100010000001100101011100100111001001101111011100100111001100100000011000010110111001100100001000000110100101110011001000000111010001101000011001010010000001101101011000010111001101110100011001010111001000100000011011110110011000100000011101000110100001100101001000000111010101101110011010010111011001100101011100100111001101100101001000000011101100101001
    translate me to text
    Ah we-a blaze the fyah, make it bun dem!

  9. #8
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    you making some kind of "he-man "joke with the master of the universe thing? lol :P

  10. #9
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah
    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

  11. #10
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    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...

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  12. The Following User Says Thank You to why06 For This Useful Post:

    Hell_Demon (11-02-2009)

  13. #11
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    How about a 3 key keyboard?

  14. The Following User Says Thank You to B1ackAnge1 For This Useful Post:

    why06 (11-02-2009)

  15. #12
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Lol. Those are the only keys you need I guess. haha!

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Similar Threads

  1. [Help] Bitwise operators
    By Nathan in forum Coders Lounge
    Replies: 9
    Last Post: 09-17-2011, 04:24 AM
  2. d.vel.oper
    By Jeckels in forum WarRock - International Hacks
    Replies: 14
    Last Post: 10-16-2007, 01:53 PM
  3. Operation Northwoods
    By Grim09 in forum General
    Replies: 12
    Last Post: 07-21-2007, 12:45 AM
  4. [RELEASE] Operation Kcah V1.0
    By ArtofLife in forum WarRock - International Hacks
    Replies: 19
    Last Post: 06-09-2007, 03:34 PM

Tags for this Thread