Results 1 to 4 of 4

Thread: Compl vs. NOT

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574

    Compl vs. NOT

    What's the difference between a compl (~) bitwise operator and a NOT (!) bitwise operator? Don't they do the same thing?

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    What language we taking here?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574
    See ;-)

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    ! is a logical operator and ~ is a bitwise operator. Take the following example:
    Code:
    int x, y, z;
    
    x = 7;
    
    y = !7;
    z = ~7;
    ! makes anything which is false (i.e 0) true (i.e. non zero) and anything which is true, false. Therefore y will become 0.

    ~ inverts each individual bit in the number. The number 7 is stored in an integer (4 bytes on most systems) an will be represented as follows in memory:

    11100000 00000000 0000000 00000000

    The ~ operator changes all the 1's to 0's and all the 0's to 1's. Changing the number to this:

    00011111 11111111 11111111 11111111

    As this is a signed integer the above is -8. Therefore z beomes -8.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width