/ Published in: Java
This Utility Class will receive two big number and do the Bitwise Operation on them using specific radix.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.math.BigInteger; /** * @author Mehdi */ public class Launcher { System.out.println(BitwiseUtils.doBitwise("00101010", "00001111", 2, BitwiseUtils.BitwiseOperator.XOR)); } } class BitwiseUtils { public enum BitwiseOperator { AND, OR, XOR } switch (bitwiseOperator) { case AND: return bn1.and(bn2).toString(radix); case OR: return bn1.or(bn2).toString(radix); case XOR: return bn1.xor(bn2).toString(radix); } return null; } }