LoginSignup
0
0

More than 1 year has passed since last update.

Java8で16進数の論理和を計算するのだ。

Last updated at Posted at 2022-12-08

いきさつ

  • 仕事で論理和のコードを書くことになったのだけれど、完全に忘れていたので調査した次第なのだ。

論理和とは

書いてみた

main.java
public static void calcOr(){
    Integer num1 = Integer.decode("0x007F");
    Integer num2 = Integer.decode("0x0030");
    
    Integer or = num1 | num2;
    System.out.println("OR(Decimal) : " + or);    // OR(Decimal) : 127
    System.out.println("OR(Hex) : " + Integer.toHexString(or));   // OR(Hex) : 7f
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0