Browse Definitions :
Definition

# operator

## What is an operator in mathematics and programming?

In mathematics and computer programming, an operator is a character that represents a specific mathematical or logical action or process. For instance, "x" is an arithmetic operator that indicates multiplication, while "&&" is a logical operator representing the logical AND function in programming.

Depending on its type, an operator manipulates an arithmetic or logical value, or operand, in a specific way to generate a specific result. From handling simple arithmetic functions to facilitating the execution of complex algorithms, like security encryption, operators play an important role in the programming world.

Mathematical and logical operators should not be confused with a system operator, or sysop, which refers to a person operating a server or the hardware and software in a computing system or network.

## Operators and logic gates

In computer programs, Boolean operators are among the most familiar and commonly used sets of operators. These operators work only with true or false values and include the following:

• AND
• OR
• NOT
• AND NOT
• NEAR

These operators and variations, such as XOR, are used in logic gates.

Boolean operators can also be used in online search engines, like Google. For example, a user can enter a phrase like "Galileo AND satellite" -- some search engines require the operator be capitalized in order to generate results that provide combined information about both Galileo and satellite.

## Types of operators

There are many types of operators used in computing systems and in different programming languages. Based on their function, they can be categorized in six primary ways.

### 1. Arithmetic operators

Arithmetic operators are used for mathematical calculations. These operators take numerical values as operands and return a single unique numerical value, meaning there can only be one correct answer.

The standard arithmetic operators and their symbols are given below.

 Symbol Operation Explanation + Addition (a+b) This operation adds both the operands on either side of the + operator. - Subtraction (a-b) This operation subtracts the right-hand operand from the left. * Multiplication (a*b) This operation multiplies both the operands. / Division (a/b) This operation divides the left-hand operand by the operand on the right. % Modulus (a%b) This operation returns the remainder after dividing the left-hand operand by the right operand.

### 2. Relational operators

Relational operators are widely used for comparison operators. They enter the picture when certain conditions must be satisfied to return either a true or false value based on the comparison. That's why these operators are also known as conditional operators.

The standard relational operators and their symbols are given below.

 Symbol Operation Explanation == Equal (a==b) This operator checks if the values of both operands are equal. If yes, the condition becomes TRUE. != Not equal (a!=b) This operator checks if the values of both operands are equal. If not, the condition becomes TRUE. > Greater than (a>b) This operator checks if the left operand value is greater than the right. If yes, the condition becomes TRUE. < Less than (a= Greater than or equal (a>=b) This operator checks if the left operand value is greater than or equal to the value of the right. If either condition is satisfied, the operator returns a TRUE value. <= Less than or equal (a<=b) This operator checks if the left operand value is less than or equal to the value of the right. If either condition is satisfied, the operator returns a TRUE value.

### 3. Bitwise operators

Bitwise operators are used to manipulate bits and perform bit-level operations. These operators convert integers into binary before performing the required operation and then showing the decimal result.

The standard bitwise operators and their symbols are given below.

 Symbol Operation Explanation & Bitwise AND (a&b) This operator copies a bit to the result if it exists in both operands. So, the result is 1 only if both bits are 1. | Bitwise OR (a|b) This operator copies a bit to the result if it exists in either operand. So, the result is 1 if either bit is 1. ^ Bitwise XOR (a^b) This operator copies a bit to the result if it exists in either operand. So, even if one of the operands is TRUE, the result is TRUE. However, if neither operand is TRUE, the result is FALSE. ~ Bitwise NOT (~a) This unary operator flips the bits (1 to 0 and 0 to 1).

### 4. Logical operators

Logical operators play a key role in programming because they enable a system or program to take specific decisions depending on the specific underlying conditions. These operators take Boolean values as input and return the same as output.

The standard logical operators and their symbols are given below.

 Symbol Operation Explanation && Logical AND (a&&b) This operator returns TRUE only if both the operands are TRUE or if both the conditions are satisfied. It not, it returns FALSE. || Logical OR (a||b) This operator returns TRUE if either operand is TRUE. It also returns TRUE if both the operands are TRUE. If neither operand is true, it returns FALSE. ! Logical NOT (!a) This unary operator returns TRUE if the operand is FALSE and vice versa. It is used to reverse the logical state of its (single) operand.

### 5. Assignment operators

Assignment operators are used to assign values to variables. The left operand is a variable, and the right is a value -- for example, x=3.

The data types of the variable and the value must match; otherwise, the program compiler raises an error, and the operation fails.

The standard assignment operators and their symbols are given below.

 Symbol Operation Explanation = Assignment (a=b) This operator assigns the value of the right operand to the left operand (variable). += Add and assign (a+=b) This operator adds the right operand and the left operand and assigns the result to the left operand. Logically, the operator means a=a+b. -= Subtract and assign (a-=b) This operator subtracts the right operand from the left operand and assigns the result to the left operand. Logically, the operator means a=a-b. *= Multiply and assign (a*=b) This operator multiplies the right operand and the left operand and assigns the result to the left operand. Logically, the operator means a=a*b. /= Divide and assign (a/=b) This operator divides the left operand and the right operand and assigns the result to the left operand. Logically, the operator means a=a/b. %= Modulus and assign (a%=b) This operator performs the modulus operation on the two operands and assigns the result to the left operand. Logically, the operator means a=a%b.

### 6. Increment/decrement operators

The increment/decrement operators are unary operators, meaning they require only one operand and perform an operation on that operand. They sometimes are called monadic operators.

The standard increment/decrement operators and their symbols are given below.

 Symbol Operation Explanation ++ Post-increment (a++) This operator increments the value of the operand by 1 after using its value. -- Post-decrement (a--) This operator decrements the value of the operand by 1 after using its value. ++ Pre-increment (++a) This operator increments the value of the operand by 1 before using its value. -- Pre-decrement (--a) This operator decrements the value of the operand by 1 before using its value.
This was last updated in August 2022

• User Datagram Protocol (UDP)

User Datagram Protocol (UDP) is a communications protocol primarily used to establish low-latency and loss-tolerating connections...

• Telnet

Telnet is a network protocol used to virtually access a computer and provide a two-way, collaborative and text-based ...

• big-endian and little-endian

The term endianness describes the order in which computer memory stores a sequence of bytes.

An advanced persistent threat (APT) is a prolonged and targeted cyber attack in which an intruder gains access to a network and ...

• Mitre ATT&CK framework

The Mitre ATT&CK (pronounced miter attack) framework is a free, globally accessible knowledge base that describes the latest ...

• timing attack

A timing attack is a type of side-channel attack that exploits the amount of time a computer process runs to gain knowledge about...

• employee resource group (ERG)

An employee resource group is a workplace club or more formally realized affinity group organized around a shared interest or ...

• employee training and development

Employee training and development is a set of activities and programs designed to enhance the knowledge, skills and abilities of ...

• employee sentiment analysis

Employee sentiment analysis is the use of natural language processing and other AI techniques to automatically analyze employee ...

• customer profiling

Customer profiling is the detailed and systematic process of constructing a clear portrait of a company's ideal customer by ...

• customer insight (consumer insight)

Customer insight, also known as consumer insight, is the understanding and interpretation of customer data, behaviors and ...