-------------------------------------- Java Sag is under construction: How do I do bitwise OR operation?
Please inform us if you find a non good advertisement : info.enim dot gmail.com

Best Web Hosting

dimanche 6 mai 2012

How do I do bitwise OR operation?

package org.kodejava.example.lang;

public class ORDemo {
    public static void main(String[] args) {
        int numberA = 16;
        int numberB = 4;

        //
        // Operator "|" is used for doing bitwise OR operation
        //
        int result = numberA | numberB;

        System.out.println(numberA + " | " + numberB + " = " + result);

        //
        // Print the result in binary format
        //
        System.out.println(Integer.toBinaryString(numberA) +
                " | " + Integer.toBinaryString(numberB) +
                " = " + Integer.toBinaryString(result));
    }
}

Aucun commentaire:

Enregistrer un commentaire

Best Web Hosting