Created
March 27, 2018 02:09
-
-
Save charsyam/ed32882483b33c340974811138a5caea 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 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