Java Bitwise Operators In Hindi

Java Bitwise Operators In Hindi

जावा प्रोग्रामिंग लैंग्वेज में बिटवाइज़ ऑपरेटर्स का यूज़ कंप्यूटर स्टोरेज लोकशन में बिट लेवल पर न्यूमेरिक बाइनरी डेटा शिफ्टिंग मॉडिफिकेशन शिफ्टिंग आदि ऑपरेशन में किया जाता है। बिटवाइज़ ऑपरेटर्स इंटीजर डाटा टाइप जैसे, बाइट, शॉर्ट, इंट, और लॉन्ग डाटा टाइप पर बिट शिफ्टिंग ऑपरेट करते हैं. जिसमे ये प्रोग्रामर को न्यूमेरिक वैल्यू को बाइनरी वैल्यू में रिप्रेजेंट करने मल्टीप्ल बिट्स टाइप में डायरेक्ट मेनूप्लेशन करने की परमिशन प्रोवाइड करते हैं। बिटवाइज़ ऑपरेटर्स जावा प्रोग्रामर को लो-लेवल बिट न्यूमेरिक डेटा प्रोसेसिंग या किसी प्रोग्राम एल्गोरिदम की परफॉर्मेंस को ऑप्टिमाइज़ करने में हेल्प करते है।

Java Bitwise Operators In Hindi

Bitwise Operators in the Java Programming.

  • Bitwise AND (&)
  • Bitwise OR (|)
  • Bitwise XOR (^)
  • Bitwise Complement (~)
  • Left Shift (<<)
  • Right Shift (>>)
  • Unsigned Right Shift (>>>)

Bitwise AND (&) Operator in Java Programming.

जावा प्रोग्राम में बिटवाइज़ AND ऑपरेटर (&) को दो ऑपरेंड के एक कॉमन बिट्स पर लॉजिकल AND ऑपरेशन परफॉर्म करने में हेल्प करता है। यहाँ आउटपुट रिज़ल्ट तब 1 होता है, जब दोनों बिट्स वैल्यू 1 हों, नहीं तो, यह 0 वैल्यू को डिस्प्ले करता है।

Example of the Bitwise AND (&) Operator.

public class Main

{

            public static void main(String[] args) {

        int p = 15;  // equivalent Binary value is – 1111

        int q = 9;  // equivalent Binary value is – 1001

        int output = p & q;  // Binary value output – 1001 -> Decimal- 9

        System.out.println(“Output of p & q And operator – ” + output);  // Result is – 9

    }

}

Bitwise AND (&) Operator Explanation.

  • यहाँ 15 डेसीमल की बाइनरी एक्विवैलेन्ट वैल्यू 1111 है.
  • यहाँ 9 डेसीमल की बाइनरी एक्विवैलेन्ट वैल्यू 1001 है.
  • & ऑपरेटर आउटपुट रिजल्ट के रूप में 1001 बाइनरी एक्विवैलेन्ट में 9 वैल्यू है.

Bitwise OR (|) Operator in Java Programming.

जावा प्रोग्राम में बिटवाइज़ OR ऑपरेटर (|) दो ऑपरेंड के कॉरेस्पोंडिंग वैल्यू बिट्स पर एक लॉजिकल OR डाटा टाइप ऑपरेशन परफॉर्म करने में हेल्प करता है। यहाँ आउटपुट रिजल्ट 1 वैल्यू होता है, अगर कम से कम एक बिट 1 वैल्यू है, नहीं तो, यह 0 वैल्यू के रूप में होता है।

Example of the Bitwise OR (|) Operator.

public class Main

{

            public static void main(String[] args) {

        int p = 15;  // equivalent Binary value is – 1111

        int q = 9;  // equivalent Binary value is – 1001

        int output = p | q;  // Binary value output – 1111 -> Decimal- 15

        System.out.println(“Output of p | q Or operator – ” + output);  // Result is – 15

    }

}

Bitwise OR (|) Operator Explanation.

  • यहाँ 15 डेसीमल की बाइनरी एक्विवैलेन्ट वैल्यू 1111 है.
  • यहाँ 9 डेसीमल की बाइनरी एक्विवैलेन्ट वैल्यू 1001 है.
  • | ऑपरेटर आउटपुट रिजल्ट के रूप में 1111 बाइनरी एक्विवैलेन्ट में 15 वैल्यू है.

Bitwise XOR (^) Operator in Java Programming.

जावा प्रोग्राम में बिटवाइज़ XOR एक्सक्लूसिव OR ऑपरेटर (^) दो प्रोग्राम ऑपरेंड वैल्यू के कॉरेस्पोंडिंग बिट्स पर एक लॉजिकल XOR ऑपरेशन परफॉर्म करने में हेल्प करता है। यहाँ दोनों ^ XOR एक्सक्लूसिव OR बिट्स डिफरेंट वैल्यू हैं, तो रिजल्ट आउटपुट के रूप में 1 होता है, नहीं तो, यहाँ रिजल्ट के रूप मे 0 वैल्यू होता है।

Example of the Bitwise XOR (^) operator.

public class Main

{

            public static void main(String[] args) {

        int p = 15;  // equivalent Binary value is – 1111

        int q = 9;  // equivalent Binary value is – 1001

        int output = p ^ q;  // Xor Binary value output – 0110 -> Decimal- 6

        System.out.println(“Output of p ^ q XOr operator – ” + output);  // Result is – 6

    }

}

Bitwise XOR (^) operator explanation.

  • यहाँ 15 डेसीमल की बाइनरी एक्विवैलेन्ट वैल्यू 1111 है.
  • यहाँ 9 डेसीमल की बाइनरी एक्विवैलेन्ट वैल्यू 1001 है.
  • ^ ऑपरेटर आउटपुट रिजल्ट के रूप में 1111 बाइनरी एक्विवैलेन्ट में 6 वैल्यू है.

Bitwise Complement (~) Operator in Java Programming.

जावा प्रोग्राम में बिटवाइज़ कॉम्प्लिमेंट ऑपरेटर (~) का यूज़ बिट डाटा ऑपरेंड के हर डाटा बिट वैल्यू को इनवर्ट या रिवर्स करने में किया जाता है। इसका अर्थ है कि बाइनरी वैल्यू 0, 1 में कन्वर्ट हो जाते हैं, और वैल्यू 1, 0 कन्वर्ट हो जाते हैं। बिटवाइज़ कॉम्प्लिमेंट को वन्स कॉम्प्लिमेंट के रूप में भी जाना जाता है।

Element of the Bitwise Complement (~) Operator.

  • यहाँ यूनरी ऑपरेटर सिंगल ऑपरेंड पे एक समय में काम करता है।
  • ये रिजल्ट के रूप में टूज़ कॉम्प्लिमेंट रिप्रेजेंटेशन को फोकस करते हुए, वैल्यू का नेगेशन करते है।

Example of the Bitwise Complement (~) Operator.

public class Main

{

            public static void main(String[] args) {

        int p = 15;  // Equivalent Binary values – 0000 0000 0000 0000 0000 0000 0000 1111 (32-bit binary value representation)

        int output = ~p;  // Binary Complement output value – 1111 1111 1111 1111 1111 1111 1111 0000 -> Decimal -16

        System.out.println(“The output is Bitwise Complement (~) of ~p – ” + output);  // Result – 16

    }

}

Bitwise Complement (~) Operator Explanation.

  • यहाँ बिटवाइज़ कॉम्प्लिमेंट ऑपरेटर 15 का टूज़ कॉम्प्लिमेंट रिप्रेजेंटेशन (32-bit में) 0000 0000 0000 0000 0000 0000 0000 1111 वैल्यू है।
  • यहाँ कॉम्प्लिमेंट (~) लगाने से सभी बिट्स वैल्यू रिवर्स हो जाते हैं, जिससे 1111 1111 1111 1111 1111 1111 1111 0000 क्रिएट होती है. जो 16 वैल्यूज का टूज़ कॉम्प्लिमेंट वैल्यू को रिप्रेजेंटेशन करता है।

Left Shift (<<) Operator in Java Programming.

जावा प्रोग्राम में लेफ्ट शिफ्ट ऑपरेटर (<<) नंबर के बिट्स वैल्यू को एक फिक्स दी गई न्यूमेरिक वैल्यू में बाईं ओर शिफ्ट या मूव करता है। यहाँ बिट शिफ्टिंग प्रोसेस में हर लेफ्ट शिफ्ट ऑपरेशन नंबर को 2 से मल्टिप्लाय करने के इक्वल है। जहा ज़ीरो सबसे दाएं बिट्स में शिफ्ट हो जाते हैं।

Example of the Left Shift (<<) Operator.

public class Main

{

            public static void main(String[] args) {

        int p = 15;  // here decimal Binary equivalent value is – 0000 0000 0000 0000 0000 0000 0000 1111 (32-bit decimal to binary representation)

        int result = p << 2;  // here left Shifts bits 2 places to the left is – 60 (Binary – 0000 0000 0000 0000 0000 0000 0011 1100)

        System.out.println(“The Output of p left shift operation is << 2 – ” + result);  // Result is – 60

    }

}

Explanation of the Left Shift (<<) operator.

  • यहाँ 15 डेसीमल वैल्यू का बाइनरी कन्वर्शन 00000000 00000000 00000000 00001100 बाइनरी 32 बिट वैल्यू में है।
  • यहाँ 15 डेसीमल वैल्यू का बाइनरी वैल्यू को 2 पोजीशन से लेफ्ट शिफ्ट करने पर रिजल्ट बाइनरी वैल्यू में 0000 0000 0000 0000 0000 0000 0011 1100 बाइनरी  60 वैल्यू है.

As a result.

  • 15  * 2^2 = 15 * 4 = 60

Right Shift (>>) Operator in Java Programming.

जावा प्रोग्राम में राइट शिफ्ट ऑपरेटर (>>) नंबर के बिट्स वैल्यू को एक फिक्स दी गई न्यूमेरिक पोजीशन से राइट साइड में डाटा वैल्यू को बिट में शिफ्ट या मूव करता है। यहाँ हर राइट शिफ्ट प्रोसेस में ऑपरेशन नंबर को 2 से डिवाइड करने के इक्वल है, जहा नेगेटिव न्यूमेरिक वैल्यू के लिए नेगेटिव इनफिनिटी की ओर राउंडिंग के साथ इसे यूज़ करते है। जहा राइट शिफ्ट ऑपरेशन प्रोसेस में बाईं ओर के बिट्स साइन बिट से फील किए जाते हैं, इस प्रोसेस को अरिथमेटिक शिफ्ट के रूप में जाना जाता हैं।

Example of the Right Shift (>>) Operator.

public class Main

{

            public static void main(String[] args) {

        int p = 15;  // here decimal Binary equivalent value is – 0000 0000 0000 0000 0000 0000 0000 1111 (32-bit decimal to binary representation)

        int result = p >> 2;  // here right Shifts bits 2 places to the right is -> 3 (Binary – 0000 0000 0000 0000 0000 0000 0011 1100)

        System.out.println(“The Output of p right shift operation is >> 2 – ” + result);  // Result is – 3

    }

}

Right Shift (>>) Operator Explanation.

  • यहाँ 15 डेसीमल वैल्यू के एक्विवैलेन्ट 00000000 00000000 00000000 00001100 32 बिट बाइनरी वैल्यू है।
  • यहाँ इस वैल्यू को 2 पोजीशन से राइट शिफ्ट मूव करने पर 0000 0000 0000 0000 0000 0000 0011 1100 एक्विवैलेन्ट बाइनरी 3 आउटपुट वैल्यू है.

As a result.

  • 15 / 2^2 = 15 / 4 = 3

Detail explanation of Bitwise Operators.

OperatorBitwise DescriptionBitwise Operator Example
&Bitwise AND operator used to Sets each bit to 1 if both bits are in 1 naturep & q
|Bitwise OR operator used to Sets each bit to 1 if both bits are in 1 naturep | q
^Bitwise XOR operator used to Sets each bit to 1 if only one of the bits is 1 in naturep ^ q
~Bitwise complement operator Inverts all the bits value.~p
<< Left shift operator used to Shifts bits to the left by a specified number of positions given by user.p << n
>> Right shift operator used to Shifts bits to the right, filling with the sign bit value.p >> n
>>> Unsigned right shift operator used to Shifts bits to the right, filling with 0s values.p >>> n

Unsigned Right Shift (>>>) Operator in Java Programming.

जावा प्रोग्राम में अनसाइन्ड राइट शिफ्ट ऑपरेटर (>>>) बिट्स डाटा वैल्यू को दाईं ओर शिफ्ट या मूव करता है, लेकिन यह सबसे बिट शिफ्टिंग प्रोसेस में बाईं ओर के बिट्स को ज़ीरो से फील कर देता है। अनसाइन्ड राइट शिफ्ट ऑपरेटर का यूज़ अनसाइन्ड इंटीजर डाटा वैल्यू के साथ किया जाता है, और सामान्य रूप से उन वैल्यू पर बिटवाइज़ ऑपरेशन प्रोसेस को हैंडल करने में अप्लाई किया जाता है. जिन्हें अनसाइन्ड वैल्यू शिफ्टिंग के रूप में जाना जाता है।

Unsigned Right Shift (>>>) Operator Example.

public class Main

{

            public static void main(String[] args) {

        int p = -15;  // here decimal Binary equivalent value is – 1111 1111 1111 1111 1111 1111 1111 0001 (32-bit decimal to binary representation)

        int result = p >>> 2;  // here Unsigned Right Shift bits 2 places and fill value with zero

        System.out.println(“The Output of p Unsigned Right Shift operation is >>> 2 – ” + result);  // Result is – 1073741820

    }

}

Unsigned Right Shift (>>>) Operator Explanation.

  • यहाँ अनसाइन्ड राइट शिफ्ट नेगेटिव नंबर वैल्यू सिचुएशन में अनसाइन्ड राइट शिफ्ट ऑपरेटर सबसे बाईं ओर के बिट्स को साइन बिट (1) के बजाय 0 वैल्यू से फील कर देता है।
  • जिसमे रिज़ल्ट एक पॉज़िटिव नंबर वैल्यू होता है, जो की रेगुलर राइट शिफ्ट ऑपरेशन (>>) के रिज़ल्ट से थोड़ा डिफरेंट होता है।

Leave a Reply