ComputersProgramming

Logical operation. Basic logical operations

Informatics as a science about the methods of collecting, organizing and processing various data begins its development in the middle of the twentieth century. Although some historians believe that the beginning of the formation of informatics was laid back in the 17th century, with the invention of the first mechanical calculator, most associate it with the era of more advanced computer technology. In the 40s of the 20th century, with the advent of the first computers, computer science received a new impulse in development.

The subject of computer science

It was with the advent of the first computers that it became necessary to develop new methods for systematization, calculation and processing of large data sets, as well as in the development of algorithms that would make use of the full potential of new computers. Informatics received the status of an independent scientific discipline and moved from the plane of mathematical calculations to the study of calculation in general.

All modern computer science is based on logical operations. They can be called a fundamental component. In the programming of computing systems, the concept of a logical operation is an action, after which a new concept or value is generated, formed on the basis of already existing concepts. A set of similar actions can vary depending on the processor element that should execute the commands. However, there are some operations that are common to virtually all existing systems. These are operations that work with the content of the values themselves, for example, negation, or those that change the quantitative characteristics of the concept - addition, subtraction, multiplication, division.

Types of operands of logical operations

Since the algebra of logic implies work on abstract concepts, then as the operands of all logical operations, generalized data types act. The classical elements with which the propositional algebra works are statements that are false or true. In electronics and programming, Boolean variables true and false or integer values of 1 (true) and 0 (false) are used to describe these terms. On a combination of these values, however incredible it may sound, the work of the most complex and large-scale systems is tied. All the code that runs on the computer or any digital device is dynamically translated into a sequence of ones and zeros - a universal code that can be processed by any processor.

Types of logical operations

As it was said before, in classical Boolean algebra there are 2 types of functions. The basic logical operations on binary data types are actions that affect the statement itself (unary, or single, operation). This includes operations that generate new statements based on existing values (binary operations, or binary). The order of logical operations is the same as for any mathematical calculations: from left to right, with brackets in mind.

The simplest and one of the most famous functions of Boolean logic is the negation function. This simplest logical operation is the opposite value of the input operand. In electronics, this action is sometimes called inversion. For example, if you invert the proposition "truth", then the result is a "lie". And vice versa - negating the meaning of "lie" will result in the value of "truth". Such a logical operation in programming is very often used for branching algorithms and implementing the "choice" of the subsequent instruction set based on already available results or changed conditions.

Binary operations

In programming and computer science, a limited set of binary (binary) operations is used. They got their name from the Latin word bi, meaning "two", and are a kind of function that takes two arguments at the input and returns one new value as a result. The truth tables are used to describe all functions of Boolean algebra.

What are they needed for

This system is composed for a certain number of input operands and describes all the resulting values that a given logical operation can return with the specified set of input parameters.

The most frequently used functions in computer science and computer science are operations of logical addition (disjunction) and logical multiplication (conjunction).

Conjunction

Logical operation "AND" is a function of choosing the smallest of the two or n input operands. At the input, this function can have two (binary function), three values (ternary) or an unlimited number of operands (n-ary operation). When calculating the result of a function, it becomes the smallest of the provided input values.

The analogue in ordinary algebra is the multiplication function. Therefore, the operation of a conjunction is often called logical multiplication. When writing a function, the sign is either a multiplication symbol (dot) or an ampersand. If you create a truth table for this function, you will see that the function takes the value "true", or 1, only if all input operands are true. If at least one of the input parameters is zero, or the value is "false," the result of the function will also be "false".

This reflects the analogy with arithmetic multiplication: multiplying any number and a set of numbers by 0 will always return 0 as a result. This logical operation is commutative: the order in which it receives input parameters will not affect the final result of the calculation in any way.

Another property of this function is associativity, or combination. This property allows you to ignore the calculation order when calculating a sequence of binary operations. Therefore, for 3 or more consecutive operations of logical multiplication, there is no need to take parentheses into account. In programming, this function is often used to make sure that specific commands are executed only when a set of certain conditions are met.

Disjunction

The logical operation "OR" is the form of a Boolean function, which is an analog of algebraic addition. Other names for this function are logical addition, disjunction. In the same way as the logical multiplication operation, the disjunction can be binary (calculate the value based on two arguments), ternary or n-ary.

The truth table for a given logical operation is a kind of alternative to a conjunction. The logical operation "OR" calculates the maximum result among the given arguments. The disjunction takes the value "false", or 0, only if all input parameters come with values of 0 ("false"). In any other case, the output will yield a value of "true", or 1. To record this function, the mathematical sign of addition ("plus") or two vertical bands is most often used. The second option is common in most programming languages and is preferable, because it allows you to clearly separate the logical operation from arithmetic.

Common properties of logical operations

Basic logical operations, be it unary, binary, ternary or other functions, are subject to certain rules and properties that describe their behavior. One of such fundamental properties that the above-described logical functions possess is commutativity.

This property ensures that the value of the function does not change from the permutation of the operand locations. Not all operations have this property. Unlike the conjunction and disjunction, which satisfy the commutativity requirements, the matrix multiplication function is not such, and a permutation of the factors in this operation will entail a change in the result, as well as exponentiation.

An additional aspect

Another important property, which is often used in electronics and circuitry, is the subordination of pairs of logical operations to de Morgan's laws.

These laws connect pairs of logical operations using the function of logical negation, that is, they allow one logical operation to be expressed with the help of another. For example, the function of negating a conjunction can be expressed by disjunctioning the negations of individual operands. With the help of these laws, logical operations "AND", "OR" can be mutually expressed and implemented with minimal hardware costs. This property is extremely useful in circuitry, since it saves resources in the calculation and formation of microcircuits.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.delachieve.com. Theme powered by WordPress.