Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bitwiseapp;
- /**
- *
- * @author user
- */
- public class BitwiseOperations {
- private int a;
- private int b;
- public int getA() {
- return a;
- }
- public void setA(int a) {
- this.a = a;
- }
- public int getB() {
- return b;
- }
- public void setB(int b) {
- this.b = b;
- }
- public void showlntA() {
- System.out.println("A AS NUMBER " + this.a);
- }
- public void showlntB() {
- System.out.println("B AS NUMBER " + this.b);
- }
- public void showBinaryA(){
- System.out.println("A is binary:" + Integer.toBinaryString(this.a));
- }
- public void showBinaryB(){
- System.out.println("B is binary:" + Integer.toBinaryString(this.b));
- }
- public int bitwiseOr() {
- return this.a | this.b;
- }
- public int bitwiseAnd(){
- return this.a & this.b ;
- }
- public int bitwiseXor(){
- return this.a ^ this.b ;
- }
- public int getComplementOneA(){
- return ~ this. a ;
- }
- public int getShiftRightOneA() {
- return this.a >> 1;
- }
- public int getShiftLeftOneA() {
- return this.a << 1;
- }
- public int getShiftRightA(int N){
- return a>>N;
- }
- public int setComplementOneA(){
- int A=this.a;
- return this.a=~A;
- }
- void setComplementOneACheck(){
- System.out.println(Integer.toBinaryString(a));
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement