• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

& operator

 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println("---->"+(-7&7)); prints 1
System.out.println(-2&-3); prints -4


but in the bit representation how to get the answer like this.
could anyone please explain in bit representation
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applied to integral values, the & operator means "bitwise and." For each bit position, it returns 1 if the bits in that position of both operands are 1.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic