Created
March 30, 2018 09:23
-
-
Save charsyam/90f74375b97f1f0fb756e3d2f648ba6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Test { | |
public static void main(String...args) { | |
Scanner sc = new Scanner(System.in); | |
byte bv = sc.nextByte(); | |
// 0b10000000 은 이진수로 1000 0000 을 의미합니다. | |
// & 연산을 통해서 첫번째 비트만 가져오는 것입니다. | |
System.out.printf("%d", (bv & 0b10000000) >> 7); // Byte의 가장 앞 bit를 출력하는 부분 | |
// 이 사이에 나머지 6bit를 출력하게 만들면 됩니다. | |
// 0b00000001 은 이진수로 0000 0001 을 의미합니다. | |
// & 연산을 통해서 마지막 비트만 가져오는 것입니다. | |
System.out.printf("%d\n", (bv & 0b00000001)); // Byte 의 가장 앞 bit를 출력하는 부분 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment