WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go - Operators


Go - Operators compiler to perform specific mathematical or logical manipulations.

Go language is rich in built-in operators and provides the following types of operators
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Miscellaneous Operators

Arithmetic Operators

mathematics operators supported by using Go language. Assume variable A holds 15 and variable B holds 30 then

Operator Description Example
+ Adds two operands A + B gives 45
- Subtracts 2nd operand from the primary A - B offers -15
* Multiplies both operands A * B offers 450
/ Divides the numerator with the aid of the denominator. B / A offers 2
% Modulus operator; offers the remainder after an integer department. B % A offers 0
++ Increment operator. It will increase the integer value via one. A++ gives sixteen
-- Decrement operator. It decreases the integer fee by using one. A-- offers 14

Show Examples


Relational Operators

Assume variable A holds 10 and variable B holds 20, then
Operator Description Example
== It tests if the values of operands are equal or not; if sure, the condition turns into authentic. (A == B) isn't always authentic.
!= It tests if the values of two operands are identical or now not; if the values are not same, then the circumstance turns into actual. (A != B) is proper.
> It assessments if the price of left operand is more than the value of proper operand; if yes, the circumstance turns into actual. (A > B) is not true.
< It checks if the fee of left operand is less than the fee of the proper operand; if yes, the situation will become true. (A < B) is genuine.
>= It assessments if the value of the left operand is greater than or equal to the value of the right operand; if sure, the situation will become true. (A >= B) isn't always authentic.
<= It assessments if the fee of left operand is much less than or same to the value of right operand; if sure, the situation turns into real. (A <= B) is actual.

Show Examples

Logical Operators

The following table lists all of the logical operators supported by using Go language. Assume variable A holds 1 and variable B holds zero, then
Operator Description Example
&& Called Logical AND operator. If each the operands are non-zero, then condition turns into genuine. (A && B) is false Called Logical OR Operator. If any of the 2 operands is non-0, then condition turns into propertrue.
! Called Logical NOT Operator. Use to reverses the logical country of its operand. If a condition is genuine then Logical NOT operator will make false. !(A && B) is proper.
The following desk shows all the logical operators supported by way of Go language. Assume variable A holds real and variable B holds fake, then
Operator Description Example
&& Called Logical AND operator. If both the operands are fake, then the situation becomes fake. (A && B) is fake Called Logical OR Operator. If any of the two operands is actual, then the circumstance becomes realactual.
! Called Logical NOT Operator. Use to reverses the logical state of its operand. If a situation is actual, then Logical NOT operator will make it fake. !(A && B) is actual.

Show Examples

Bitwise Operators

There are following listing of bitwise operator:
p q p & q p 0 0 0 0 zero
0 1 zero 1 1
1 1 1 1 0
1 0 zero 1 1

Assignment Operators

There are following listing of venture operators.
Operator Description Example
= Simple task operator, Assigns values from proper facet operands to left aspect operand C = A + B will assign value of A + B into C
+= Add AND venture operator, It provides right operand to the left operand and assign the result to left operand C += A is equal to C = C + A
-= Subtract AND assignment operator, It subtracts proper operand from the left operand and assign the result to left operand C -= A is equivalent to C = C - A
*= Multiply AND assignment operator, It multiplies right operand with the left operand and assign the end result to left operand C *= A is equal to C = C * A
/= Divide AND mission operator, It divides left operand with the proper operand and assign the end result to left operand C /= A is equivalent to C = C / A
%= Modulus AND task operator, It takes modulus the usage of two operands and assign the end result to left operand C %= A is equal to C = C % A
<<= Left shift AND undertaking operator C <<= 2 is identical as C = C << 2
>>= Right shift AND challenge operator C >>= 2 is same as C = C >> 2
&= Bitwise AND mission operator C &= 2 is same as C = C & 2
^= bitwise specific OR and task operator C ^= 2 is equal=