Skip to content

Instantly share code, notes, and snippets.

@charsyam
Created March 27, 2018 02:09
Show Gist options
  • Save charsyam/ed32882483b33c340974811138a5caea to your computer and use it in GitHub Desktop.
Save charsyam/ed32882483b33c340974811138a5caea to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class ShowByteBits {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
byte bv = sc.nextByte();
System.out.printf("%d", (bv & 0x80) >> 7); // Byte의 가장 앞 bit를 출력하는 부분
// 이 사이에 나머지 6bit를 출력하게 만들면 됩니다.
System.out.printf("%d\n", (bv & 0x01)); // Byte 의 가장 앞 bit를 출력하는 부분
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment