Data

Julie Oh·2025년 7월 17일

Operating system

목록 보기
2/14

💾 Data Representation in Binary

❓ Q. Computers only understand binary — so how do they handle numbers like 2 or 3?

✅ A. All data and instructions are converted into binary (0s and 1s).
The smallest unit of data in a computer is called a bit, which can be either 0 or 1.

🔢 Representing Numbers

🔸 How to represent negative numbers in binary?
We use two’s complement, a system that allows binary numbers to store both positive and negative values.

✅ Two conditions for two’s complement:

  • It must be a signed binary system
  • An n-bit system can represent numbers from: -2^(n−1) to 2^(n−1) − 1

    EX) For 8 bits -> range is −128 to +127

✏️ Example: Represent −11 in 8-bit two’s complement
Start with +11 in binary:

+11 = 00001011
  1. Flip the bits(invert):
    -> 1110100
    2) Add 1:
    -> 1110100 + 1 = 1110101

🔟 Hexadecimal
❓ Q. If computers only understand binary, why do we use hexadecimal?
✅ A. Hexadecimal (base-16) is a human-friendly way to write binary.
Each hex digit = 4 binary bits, so it's easy to convert between the two.

🔡 Representing Characters

📚 Character Set
A character set is a collection of characters that can be encoded into binary and decoded back into characters.

🔁 Encoding & Decoding
Encoding: The process of converting characters into binary
Decoding: The process of converting binary back into characters

🔢 ASCII Code
ASCII Code is the numeric value assigned to each ASCII character.

The result of encoding is binary, but it's based on the ASCII code (a number).

Example: 'A' → ASCII code 65 → Binary 01000001

🌐 Unicode
Unicode is a universal character set that includes characters from many languages, as well as symbols, emojis, and special characters.

Unicode characters are also represented by numbers, and there are multiple encoding formats to represent them in binary:

  • UTF-8
  • UTF-16
  • UTF-32

Each format differs in how many bytes it uses and how efficiently it stores different kinds of characters.

0개의 댓글