10진수 | 2진수 | 16진수 | 8진수 | 10진수 | 2진수 | 16진수 | 8진수 | |
---|---|---|---|---|---|---|---|---|
0 | 0(0B 붙임) | 0 | 0 | |||||
1 | 0000 0001 | 0x1 | 01 | 11 | 0000 1011 | 0xB | 013 | |
2 | 0000 0010 | 0x2 | 02 | 12 | 0000 1100 | 0xC | 014 | |
3 | 0000 0011 | 0x3 | 03 | 13 | 0000 1101 | 0xD | 015 | |
4 | 0000 0100 | 0x4 | 04 | 14 | 0000 1110 | 0xE | 016 | |
5 | 0000 0101 | 0x5 | 05 | 15 | 0000 1111 | 0xF | 017 | |
6 | 0000 0110 | 0x6 | 06 | 16 | 0001 0000 | 0x10 | 020 | |
7 | 0000 0111 | 0x7 | 07 | 17 | 0001 0001 | 0x11 | 021 | |
8 | 0000 1000 | 0x8 | 010 | 18 | 0001 0010 | 0x12 | 022 | |
9 | 0000 1001 | 0x9 | 011 | 19 | 0001 0011 | 0x13 | 023 | |
10 | 0000 1010 | 0xA | 012 | 20 | 0001 0100 | 0x14 | 024 |
2진수 100101111111101111100
16진수 12ff7c
8진수 4577574
리턴 타입 | 클래스 | 메소드 | 설명 |
---|---|---|---|
static String | java.lang.Integer | toBinaryString(int i) | 10진수 -> 2진수 |
static String | java.lang.Integer | toOctalString(int i) | 10진수 -> 8진수 |
static String | java.lang.Integer | toHexaString(int i) | 10진수 -> 16진수 |
2진수 값 하나(0또는 1)를 저장할 수 있는 최소 메모리 공간
1비트 | 2비트 | 3비트 | 4비트 | .................... | ||
---|---|---|---|---|---|---|
표현가능 데이터 | 2 = 2개 | 2² = 4개 | 2³ = 8개 | 2⁴ = 16개 | 2^n개 | |
데이터 | 0, 1 | 00, 01, 10, 11 | 000, ..., 111 |
8개의 연속된 bit, 2^8(256)개의 데이터 저장공간 가짐
public class Main{
public static void main(String[] args) {
int a = 20;
int b = ~a;
System.out.println(b); // -21
}
}