bitwise06_05.java
8299 단어 javaprogrammingbeginnerstutorial
// ~Bitwise Operators
// problem:
// bitwise06_05.java{write java program showing the working of all Bitwise Operators.}
class bitwise06_05
{
public static void main(String args[])
{
int a= 2, b=3;
System.out.println("Value of a = "+a+" and value of b = "+b);
System.out.println("Binary value of a and b is = "+Integer.toBinaryString(a)+" "+Integer.toBinaryString(b));
// System.out.println("The Bitwise operators work on the terms of binary notation. ");
System.out.println("Bitwise OR "+a+" | "+b+" => "+(a|b));
System.out.println("The Binary notation of a and b is = 00000010 00000011");
System.out.println("The Truth Table of OR Bitwise Operator is \n A \t B \t OUTPUT \n ----------------------- \n 0 \t 0 \t 0 \n 1 \t 0 \t 1 \n 0 \t 1 \t 1 \n 1 \t 1 \t 1\n ----------------------- ");
System.out.println("according to truth table answer is 00000010 | 00000011 = 00000011 = 3\n");
System.out.println("Bitwise AND "+a+" & "+b+" => "+(a&b));
System.out.println("The Binary notation of a and b is = 00000010 00000011");
System.out.println("The Truth Table of AND Bitwise Operator is \n A \t B \t OUTPUT \n ----------------------- \n 0 \t 0 \t 0 \n 1 \t 0 \t 0 \n 0 \t 1 \t 0 \n 1 \t 1 \t 1\n ----------------------- ");
System.out.println("according to truth table answer is 00000010 & 00000011 = 00000010 = 2\n");
System.out.println("Bitwise XOR "+a+" ^ "+b+" => "+(a^b));
System.out.println("The Binary notation of a and b is = 00000010 00000011");
System.out.println("The Truth Table of XOR Bitwise Operator is \n A \t B \t OUTPUT \n ----------------------- \n 0 \t 0 \t 0 \n 1 \t 0 \t 1 \n 0 \t 1 \t 1 \n 1 \t 1 \t 0\n ----------------------- ");
System.out.println("according to truth table answer is 00000010 ^ 00000011 = 00000001 = 1\n");
System.out.println("Bitwise NOT ~ "+a+" => "+(~a));
System.out.println("The Binary notation of a is = 00000010");
System.out.println("The Truth Table of NOT Bitwise Operator is \n A \t OUTPUT \n ----------------------- \n 0 \t 1 \n 1 \t 0 \n----------------------- ");
System.out.println("according to truth table answer is ~00000010 = 11111101 = -3\n");
System.out.println("ENDING THE PROGRAM...\n:-) THANK YOU (-:");
}
}
Reference
이 문제에 관하여(bitwise06_05.java), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/ukantjadia/bitwise0605java-18a7텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)