Page 6 of 6 FirstFirst ... 3456
Results 51 to 54 of 54
  1. #51

    Quote Originally Posted by Sarevok View Post
    kay bored ko, ako ning buhion balik

    [Programming Language]
    C/C++ (I think applicable sa tanan)

    [Question]
    Recently naay programming question na nisikat sa interwebs which is this:

    If x is an (binary) integer, what does (x & -x) compute?
    x & -x returns 1 if bot bits are 1. else 0.

    for example:
    x = 15;
    y = 9;

    z = x & y;

    x = 1111
    y = 1001
    -------------
    z = 1001

    so x & y yields 9 of decimal 1001.

    & is bitwise operator.

  2. #52
    C.I.A. Sarevok's Avatar
    Join Date
    Apr 2007
    Gender
    Male
    Posts
    2,802
    Blog Entries
    4
    Quote Originally Posted by Zer0Degree View Post
    x & -x returns 1 if bot bits are 1. else 0.

    for example:
    x = 15;
    y = 9;

    z = x & y;

    x = 1111
    y = 1001
    -------------
    z = 1001

    so x & y yields 9 of decimal 1001.

    & is bitwise operator.
    sakto imo definition sa bitwise AND operator, pero ang question kay what is x & -x (read x AND two's complement of x)

  3. #53
    Quote Originally Posted by Sarevok View Post
    sakto imo definition sa bitwise AND operator, pero ang question kay what is x & -x (read x AND two's complement of x)
    i dont get u. if you want to get the binary digit of negative integer, then get it and make an expression of & with a postive x : )

  4. #54
    C.I.A. Sarevok's Avatar
    Join Date
    Apr 2007
    Gender
    Male
    Posts
    2,802
    Blog Entries
    4
    Quote Originally Posted by Zer0Degree View Post
    i dont get u. if you want to get the binary digit of negative integer, then get it and make an expression of & with a postive x : )
    But you missed the main question which is, "What does x & -x compute?". What do you get when you do this operation?

  5.    Advertisement

Page 6 of 6 FirstFirst ... 3456

Similar Threads

 
  1. what is your favorite programming language?
    By sachem in forum Programming
    Replies: 310
    Last Post: 10-08-2015, 03:11 PM
  2. Python programming questions
    By Louis in forum Programming
    Replies: 8
    Last Post: 09-10-2014, 10:51 AM
  3. Beware of 'tricked out' Hijack program
    By cliff_drew in forum Software & Games (Old)
    Replies: 4
    Last Post: 06-24-2009, 02:38 PM
  4. Boot using USB w/ different programs (question)
    By babolgam in forum Computer Hardware
    Replies: 5
    Last Post: 01-22-2009, 11:17 AM
  5. question on networking programming
    By poymode in forum Programming
    Replies: 6
    Last Post: 12-29-2008, 08:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top