2023 2024 Student Forum > Management Forum > Main Forum

 
  #2  
10th April 2013, 02:14 PM
Super Moderator
 
Join Date: May 2012
Re: BITS Java Programming

The Java programming language also provides operators that execute bitwise and bit shift operations on integral types.

The operators discussed in this section are less usually used. Therefore, their coverage is brief; the intent is to simply make you aware that these operators exist.

The signed left shift operator "<<" shifts a bit pattern to the left, and
The signed right shift operator ">>" shifts a bit pattern to the right

The bitwise & operator performs a bitwise AND operation.

The bitwise ^ operator performs a bitwise exclusive OR operation.

The bitwise | operator performs a bitwise inclusive OR operation.

The following program, BitDemo, uses the bitwise AND operator to print the number "2" to standard output.

class BitDemo {
public static void main(String[] args) {
int bitmask = 0x000F;
int val = 0x2222;
// prints "2"
System.out.println(val & bitmask);
}
}


Tags
bits pilani

Quick Reply
Your Username: Click here to log in

Message:
Options




All times are GMT +5. The time now is 06:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
SEO by vBSEO 3.6.0 PL2

1 2 3 4