費曼AI標誌

二進制數字 (Binary Numbers)

Computer Science / Mathematics

Binary numbers are a way of counting using only 0s and 1s, instead of the usual 0 to 9.

簡要介紹

Imagine you only have two fingers! Binary numbers are like counting with just those two fingers. They're the foundation of how computers store and process all kinds of information, from text and pictures to videos and games. It's a simple system that allows machines to understand and manipulate data.

主要說明

Only Two Digits: 0 and 1

Unlike our everyday decimal system (base-10) which uses ten digits (0-9), binary (base-2) uses only two: 0 and 1. Think of '0' as 'off' and '1' as 'on'. This 'on/off' nature makes it perfect for representing electrical signals in computers.

Place Value is Based on Powers of 2

In the decimal system, each place value represents a power of 10 (ones, tens, hundreds, etc.). In binary, each place value represents a power of 2 (ones, twos, fours, eights, etc.). So, from right to left, the place values are 2⁰ (1), 2¹ (2), 2² (4), 2³ (8), and so on. For example, the binary number 101 means (1 x 4) + (0 x 2) + (1 x 1) = 5 in decimal.

Converting Binary to Decimal

To convert a binary number to decimal, multiply each digit by its corresponding power of 2 and then add the results. Let's take the binary number 1101. From right to left: (1 x 2⁰) + (0 x 2¹) + (1 x 2²) + (1 x 2³) = (1 x 1) + (0 x 2) + (1 x 4) + (1 x 8) = 1 + 0 + 4 + 8 = 13. So, 1101 in binary is 13 in decimal.

Converting Decimal to Binary

To convert a decimal number to binary, repeatedly divide the decimal number by 2 and keep track of the remainders. The remainders, read from bottom to top, form the binary number. For example, let's convert 10 to binary. 10 / 2 = 5 remainder 0; 5 / 2 = 2 remainder 1; 2 / 2 = 1 remainder 0; 1 / 2 = 0 remainder 1. Reading the remainders from bottom to top, we get 1010. So, 10 in decimal is 1010 in binary.

範例

  • Imagine a light switch 💡. It can be either 'on' (1) or 'off' (0). A series of light switches can represent different numbers. For example, 'on-off-on' (101) could represent the number 5.
  • Think of Morse code 📻. It uses dots (.) and dashes (-) to represent letters and numbers. You could think of dots as '0' and dashes as '1'. A combination of dots and dashes then represents a specific character, just like a combination of 0s and 1s represents a number in binary.
  • Consider a simple voting system where you can only vote 'yes' or 'no' ✅ ❌. 'Yes' could be represented by 1 and 'No' by 0. A series of votes could then be represented as a binary sequence. For example, 'yes-no-yes-yes' would be 1011.