Every Binary Operation and Logic Gate Explained

The binary system is the foundation of all computing. Without it, there would be no computers, cell phones, internet, or modern technology as we know it.

What Is the Binary System?

The binary system is a base-2 numeral system that uses only two values: 0 and 1. Unlike the decimal system, which has 10 digits (0 through 9), the binary system operates solely with these two states. In other words, it only admits two possibilities, always opposing, such as all or nothing, on and off, presence and absence, right and left, high and low, true and false, white and black. In the binary system, there are no intermediates.

Although it may seem like a limited system, it is the cornerstone of all modern computing.

Converting Between Decimal and Binary

To convert a decimal number to binary, the decimal number is divided by two and the remainders are recorded. For example, to convert the number 45 to the binary system:

  1. 45 ÷ 2 = 22 remainder 1
  2. 22 ÷ 2 = 11 remainder 0
  3. 11 ÷ 2 = 5 remainder 1
  4. 5 ÷ 2 = 2 remainder 1
  5. 2 ÷ 2 = 1 remainder 0
  6. 1 ÷ 2 = 0 remainder 1

By reading the remainders from bottom to top, 45 in binary is 101101.

To convert a binary number to decimal, each binary digit is taken and multiplied by a power of two according to its position and added. For example, to convert 101101 to decimal: (1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 32 + 0 + 8 + 4 + 0 + 1 = 45.

In the binary system, as in the decimal system, leading zeros have no value and do not affect the number. These are used only to maintain consistent formatting. For example, 00001 in binary is the same as 1.

Binary Arithmetic Operations

Just as addition, subtraction, multiplication, and division are performed in the decimal system, it is also possible to operate with these values in the binary system. The difference is that there are only two digits: 0 and 1. Binary operations are the foundation of computational arithmetic, which uses these rules to perform millions of calculations per second.

Binary Addition

Addition in binary follows rules similar to decimal addition but with only two possible numbers:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 10 (which is 0 with a 1 carried forward to the next digit)

Example: 1011 (11 in decimal) + 1101 (13 in decimal) = 11000 (24 in decimal). When two 1s are added, the result is 10, which means the zero is placed in that position and the one is carried over to the next column, just like in decimal when adding 9 + 1 and carrying one to the next position.

Binary Subtraction

Binary subtraction follows a principle similar to decimal subtraction. When subtracting 0 from 1, it is necessary to borrow from the next column, just as in the decimal system.

Example: 1010 (10 in decimal) − 0011 (3 in decimal) = 0111 (7 in decimal).

Binary Multiplication

Binary multiplication is simpler than decimal multiplication as it follows only two rules:

  • 0 × 0 = 0
  • 0 × 1 = 0
  • 1 × 0 = 0
  • 1 × 1 = 1

Example: 101 (5 in decimal) × 11 (3 in decimal) = 1111 (15 in decimal).

Binary Division

Binary division is performed the same way as in decimal, subtracting at each step and shifting the bits.

Example: 1010 (10 in decimal) ÷ 10 (2 in decimal) = 101 (5 in decimal).

Boolean Algebra and Logic Gates

The logic of electronic circuits is based on mathematical rules called Boolean algebra, which allow the simplification and analysis of logical operations. These rules are the foundation of logic gates.

Boolean algebra is a mathematical system developed by George Boole in the 19th century that works with only two values: 1 (true) and 0 (false). In other words, Boolean algebra operates directly with the binary system.

Logic gates are electronic devices that process binary signals to perform basic logical operations. Fundamental logic gates form the foundation of digital electronics. With them, complex circuits such as microprocessors, RAM memory, and storage devices are built.

Basic Logic Gates

NOT Gate (Logical Inverter)

The NOT gate inverts the input signal.

AND Gate (Logical Multiplication)

The AND gate returns 1 only if both inputs are 1. It is equivalent to Boolean multiplication.

OR Gate (Logical Addition)

The OR gate returns 1 if at least one of the inputs is 1. It is associated with Boolean addition.

Derived Logic Gates

The fundamental gates (AND, OR, and NOT) can be combined to form more complex gates. These are known as derived logic gates: NAND, NOR, XOR, and XNOR. Derived gates extend the functionalities of the basic gates and enable the creation of advanced digital circuits.

NAND Gate (AND Negation)

The NAND gate is the combination of an AND gate followed by a NOT gate. In other words, it first multiplies the values and then inverts the result. NAND gates are so versatile that they can be used to construct any other type of logic gate, including NOT, AND, and OR.

NOR Gate (OR Negation)

The NOR gate is the combination of an OR gate followed by a NOT gate. It first adds the values and then inverts the result.

XOR Gate (Exclusive OR)

The XOR gate returns 1 only when the inputs are different. It is useful in circuits where detecting changes or differences is needed.

XNOR Gate (Exclusive OR Negation)

The XNOR gate is the inversion of XOR. It returns 1 only when the inputs are the same.

Properties of Boolean Algebra

Commutative Property

  • For addition (OR): a + b = b + a
  • For multiplication (AND): a × b = b × a

Associative Property

  • For addition (OR): a + (b + c) = (a + b) + c
  • For multiplication (AND): a × (b × c) = (a × b) × c

Distributive Property

  • Distributive property of AND over OR: a × (b + c) = (a × b) + (a × c)
  • Distributive property of OR over AND: a + (b × c) = (a + b) × (a + c)

Identity Properties

  • Neutral element for OR: a + 0 = a
  • Neutral element for AND: a × 1 = a

Domination Properties

  • Domination with OR: a + 1 = 1
  • Domination with AND: a × 0 = 0

Idempotent Properties

  • For OR: a + a = a
  • For AND: a × a = a

Involution Property

  • Double negation: ¬(¬a) = a

Complement Properties

  • For OR: a + ¬a = 1
  • For AND: a × ¬a = 0

Absorption Laws

  • a + (a × b) = a
  • a × (a + b) = a

Further Reading

Join the ThoughtThrill Newsletter
Get new mind-expanding math explained simply, plus free access to the Math Toolkit with interactive tools, visualizers, and resources used in our articles.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *