2진수·8진수·10진수·16진수 변환 및 비트 연산
같은 수를 2진수, 8진수, 10진수, 16진수로 바꿔 보여주고 비트 연산까지 처리하는 도구입니다. 우리가 평소 쓰는 10진수는 손가락이 열 개라서 정착한 표기일 뿐, 수 자체의 성질과는 관계가 없습니다. 컴퓨터는 전기가 흐르거나 흐르지 않는 두 상태만 구분하므로 2진수를 쓰고, 사람이 그 2진수를 읽기 편하도록 만든 절충안이 16진수입니다.
chmod 755가 대표적입니다. 읽기(4)·쓰기(2)·실행(1) 세 비트가 한 자리에 딱 들어맞아 이 표기가 남았습니다.#FF5733, 메모리 주소, 바이트 덤프가 모두 16진수입니다.16진수가 널리 쓰이는 이유는 변환이 기계적이기 때문입니다. 2진수 1111 0101은 앞 네 자리가 F, 뒤 네 자리가 5라서 그대로 F5가 됩니다. 계산이 필요 없습니다.
<<1)은 2를 곱한 것, 오른쪽 한 칸(>>1)은 2로 나눈 것과 같습니다.Q. 16진수 앞에 붙는 0x는 무엇인가요?
이 값이 16진수임을 알리는 표시입니다. 10은 십진수 10일 수도, 16진수 16일 수도 있어 구분이 필요합니다. 2진수는 0b, 8진수는 0o를 씁니다.
Q. 음수는 어떻게 표현하나요?
컴퓨터는 대개 2의 보수 방식을 씁니다. 8비트에서 -1은 11111111이 되며, 이 때문에 최상위 비트가 부호 역할을 합니다.
Q. 색상 코드가 왜 16진수인가요?
빨강·초록·파랑을 각각 0~255로 표현하는데, 255는 16진수 두 자리(FF)에 정확히 들어맞습니다. 그래서 여섯 자리로 세 색을 깔끔하게 담을 수 있습니다.
This tool shows the same number in binary, octal, decimal and hexadecimal, and performs bitwise operations. Decimal is simply what humans settled on because we have ten fingers — it says nothing about the number itself. Computers distinguish only two states, current or no current, so they work in binary; hexadecimal is the compromise that makes binary readable for people.
chmod 755, because read (4), write (2) and execute (1) fit neatly into one digit.#FF5733, memory addresses and byte dumps all use it.Hex is popular because conversion is mechanical: binary 1111 0101 is F for the first four bits and 5 for the rest, giving F5 with no arithmetic at all.
<<1) multiplies by 2; right by one (>>1) divides by 2.Q. What does the 0x prefix mean?
It marks the value as hexadecimal. 10 could be ten or sixteen without it. Binary uses 0b and octal 0o.
Q. How are negative numbers represented?
Usually via two's complement. In 8 bits, −1 is 11111111, which is why the most significant bit acts as the sign.
Q. Why are color codes hexadecimal?
Red, green and blue each range 0–255, and 255 fits exactly into two hex digits (FF) — so six characters cleanly hold all three channels.