Двійкова система (Binary)

Система числення з основою 2, що використовує лише 0 та 1 — базова мова комп'ютерів.

Сучасна двійкова система була формалізована Лейбніцом. На відміну від десяткової системи, де кожна позиція є ступенем 10, позиції у двійковому коді є ступенями 2 (справа наліво: 1, 2, 4, 8...). Наприклад, число 1011 дорівнює: (1×8) + (0×4) + (1×2) + (1×1) = 11. Вісім бітів утворюють байт, який може містити 256 значень.

        graph LR
  Center["Двійкова система (Binary)"]:::main
  Rel_bit["bit"]:::related -.-> Center
  click Rel_bit "/terms/bit"
  Rel_byte["byte"]:::related -.-> Center
  click Rel_byte "/terms/byte"
  Rel_hexadecimal["hexadecimal"]:::related -.-> Center
  click Rel_hexadecimal "/terms/hexadecimal"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Простими словами

Комп'ютери не розуміють слів. Вони складаються з мільярдів крихітних вимикачів світла. Вимикач може бути УВІМКНЕНИМ (1) або ВИМКНЕНИМ (0). Двійковий код — це просто дуже довгий список сигналів 'увімк/вимк', завдяки якому працює все: від цього тексту до ігор.

🤓 Expert Deep Dive

Арифметика в АЛП виконується за допомогою логічних вентилів (AND, OR, XOR), що базуються на булевій алгебрі. Для представлення від'ємних чисел повсюдно використовується доповняльний код (Two's Complement), що дозволяє апаратним суматорам обробляти і додавання, і віднімання. Дробові числа кодуються за стандартом IEEE 754. Щодо зберігання в пам'яті (Endianness), архітектура x86 використовує Little-Endian (молодший байт записується першим).

❓ Часті питання

Why do computers use binary instead of decimal?

It's a physical limitation. It is much easier, cheaper, and reliable to build electrical switches that have only two clear states (ON/OFF or High/Low Voltage) rather than trying to accurately measure ten different voltage levels for a base-10 system.

What is the difference between a bit and a byte?

A 'bit' is a single binary digit (a single 0 or 1). A 'byte' is a group of 8 bits strung together. One byte is enough data to represent a single letter, like 'A' (which is 01000001 in binary).

How do you count in binary?

In decimal, you count 0 to 9 and then roll over to 10. In binary, you only have 0 and 1, so you roll over immediately. The counting goes: 0, 1, 10, 11, 100, 101, 110, 111 (which translates to 0, 1, 2, 3, 4, 5, 6, 7 in decimal).

📚 Джерела