answersLogoWhite

0

What are logical operators?

Updated: 8/10/2023
User Avatar

Wiki User

12y ago

Best Answer

Logical operations involve the use of three operators - NOT, AND and OR. NOT simple negates a value.

It uses one operand.

For Example - a) Not True (which means, False as True and False are the only possible values) b) Knowing English AND French (means someone who knows both English AND French) c) Knowing English OR French (means someone who knows either English or French).

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago
Arithmetic Operators

Arithmetic operators do exactly what they say, they perform simple arithmetic operations such as addition and subtraction. All arithmetic operators are binary operators, thus they all accept two input values (an lvalue and an rvalue) and output one value, the evaluation of the lvalue and rvalue.


  • + (addition)
  • - (subtraction)
  • * (multiplication)
  • / (division)
  • % (modulus) [returns the remainder of a division]


Logical Operators


Logical operators are a little more complex to explain, but they are actually just primitive operators that can be used in combination to produce more complex operators. Logical operators can be split into two categories: unary operators and binary operators. A unary operator has just one input, while a binary operator has two inputs. Logical operators are also known as bitwise operators because each operates upon corresponding bits of the operands. Since they operate at the bit-level, they are also known as boolean operators. An individual bit can only be 0 or 1 (false or true) thus we can build simple truth tables to determine what the output bit will be for any given input bit.



Logical NOT

The logical NOT operator is the simplest operator to understand because it is a unary operator and therefore has only one input. It's sole purpose is to invert the input value on a bit-by-bit basis to produce an output. Since an input bit can only ever be 1 or 0, the NOT truth table is relatively simple:


input 0 1

output 1 0


Each bit of an input is handled separately according to this table. Thus NOT(00000000) will output 11111111, while NOT(11111111) will output 00000000. Likewise, NOT(10101100) would output 01010011.


Inside your computer you will actually have at least 32 logical NOT circuits that operate simultaneously, thus allowing multi-bit values to be handled as a single operation. That is, each individual circuit operates upon one bit of the input.



Logical Binary Operators

Since binary operators have two inputs, the truth tables are a little more complex than that of the NOT operator. The two inputs are typically represented by the values p and q. The simplest operator is the AND operator, which has the following truth table:


p q output

0 0 0

0 1 0

1 0 0

1 1 1


You will note that the output is true only when both inputs are true. You will also note that there are four possible outputs for any two inputs. Thus with four possible outputs, there has to be 16 possible combinations of output. And in order to represent all possible outputs we therefore need 16 logical bitwise operators, of which the AND operator is just one.


Thus the complete truth table for all logical binary operators is as follows:


p q 0 1 2 3 4 5 6 7 8 9 A B C D E F

0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1


The outputs are represented by the hexadecimal values 0 through F. If you read down a column you will note that the combined bit values correspond to the column header. Thus the AND operator, with outputs 0001, is represented by column 1.


Columns 6 and 7 are the most interesting of the remaining columns as column 7 represents the logical OR operator while column 6 is the logical XOR operator (exclusive OR). Along with AND, these are the only three logical operators that are actually required. You might ask why we don't have operators for the remaining 13, but we do -- it's just that we don't have any specific operators for them. We simply combine the AND, OR and XOR operators with the unary NOT operator in order to achieve them.


In actual fact, the last 8 operators are simply the inverse of the first 8 (column F is the inverse of column 0, column E is the inverse of column 1, and so on). Thus NOT( p AND q ) produces the results shown in column E. This particular operator is commonly called the NAND operator. By the same token, column 8 is the NOR operator and column 9 is the XNOR operator. Most languages do not provide these specific operators but we can reproduce them using NOT with AND, OR and XOR respectively.


Columns 0 and F (the contradiction and tautology operators, respectively) are essentially redundant since they have no practical usage. However, they are logical binary operators, nevertheless.


We can summarise all the logical binary operators as follows:


0 : contradiction

1 : p AND q

2 : p AND NOT(q)

3 : p

4 : q AND NOT(p)

5 : q

6 : p XOR q

7 : p OR q

8 : p NOR q (e.g., NOT(p OR q))

9 : p XNOR q (e.g., NOT(p XOR q))

A : NOT(q)

B : NOT(q AND NOT(p))

C : NOT(p)

D : NOT(p AND NOT(q))

E : p NAND q (e.g., NOT(p AND q))

F : tautology


You will note that A and C are already catered for with the unary NOT operator alone. You will also note that 3 and 5 are the inverse of A and C, and are both known as unary projection functions. Along with 0 and F, these 6 operators are completely redundant, leaving us with 10 useful logical binary operators, all of which can be created by combining NOT with the 3 most basic operators: AND, OR and XOR.


This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Logical operator is used to COMPARE OR EVALUATE LOGICAL AND RELATIONAL EXPRESSION

An Expression that uses logical operator (&&,,!) is calles logical expression.

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

Logical OR (as opposed to bitwise OR) compares the Boolean values of two operands, returning true when one or both operands evaluates true, or false when both operands evaluate false.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are logical operators?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the uses of logical operators in Java?

Logical Operators are those that are used for doing logical operations. There are a total of 6 logical operators (&, |, ^, !, &&, and ‖) Of the six logical operators listed above, three of them (&, |, and ^) can also be used as "bitwise" operators. There are two non-short-circuit logical operators. • & non-short-circuit AND • | non-short-circuit OR There are two short-circuit logical operators • && short-circuit AND • short-circuit OR


What are different type's operators?

The different types of operators are as follows: *Arithmatic operator *Relational operator *Logical operator *Assignment operator *Increment/Decrement operator *Conditional operator *Bitwise operator *Special operator


How many types of logical operators in c only?

There are three logical operators in C; AND (&), OR (|), and NOT (^). These are the bitwise versions. The combinatorial versions are &&, , and !.


What are the operators in c tokens?

All arithmetic, logical operators are operators in c tokens. As: +, - , ++, --, %, &&, &, >>, << etc.


What is The hierarchy of the execution of logical operators?

And or not


What are 3 logical operators?

there r 4 logical operator not 3 AND, OR, XOR, and NOT


Difference between relational and logical operators?

Logical operators don't Compare values they combine Boolean values and produce a Boolean result. Examples of logical operators are && (and), , (or), ! (not). If you have two Boolean values and you combined them with the && operator the result will be (TRUE) only if both values were (TRUE). Relational operators compare two values and produce a Boolean result. Most of the time we use logical operators to combine the results of two or more comparison expressions that use relational operators.


Explain the categories of PHP Operators in web technology?

There are arithmetic operators (+, -, %, ++, etc.), comparison operators (<, ==, >=, !=, etc.), logical operators (&&, !, , etc.), assignment operators (=, *=, %=, +=, etc.), conditional operator (?:). The order of operations is unary (!, ++, --), multiplicative (left to right; *, /, %), additive (left to right; +, -), relational (left to right; <, <=, >, >=), equality (left to right; ==, !=), logical and (left to right; &&, and), logical or (left to right; , or), conditional (?:), assignment.


What is the job of an logical operator?

Logical operators can be used when searching in a search engine. They can be used to help you find more specific information. Logical operators are things like quotation marks and commas and speach mrks.


Advantages of logical operators over relational operators using If Then ElseIf statement?

you are a full time wanker.


What do you understand by operators in BASIC?

Operators are the symbols, which are used to perform different arithmetical and logical operations in BASIC.


What are the different types of operations of c?

c have different types of operations are there these are 1:logical operators 2:conditional 3:arithmetic 4:bit wise operators 5:increment&decrement 6:relational operators 7:assignment operators 8:special operators we can use above operators. we can implementing the operations. suppose logical operators &&,,! by using these we can implement operations