Numeric operators : Perl Script « Language Basics « Perl






Numeric operators

   

OPERATOR            PURPOSE

+                   Computes the additive value of the two operands.

                   Computes the difference between the two operands.

*                   Computes the multiplication of the two operands.

/                   Computes the division between the two operands.

%                   Computes the modulus (remainder) of the two operands.

==                  Returns True if the two operands are equal, False otherwise.

!=                  Returns True if the two operands are not equal, False otherwise.

>=                  Greater than.

<=                  Less than.

>                   

<=>                 Returns -1 if the left operand is less than the right, +1 if is it greater than, and 0 (False) otherwise.

&&                  a logical AND operation. 

||                  a logical OR operation. 

&                   Returns the value of the two operators bitwise ANDed.

|                   Returns the value of the two operators bitwise ORed.

~                   Returns the value of the two operators bitwise XORed.

++                  Increment operator. Increments the variable's value by 1.

--                  Decrement operator. Decrements the variable's value by 1.

xx                  Computes the power of the left value to the power of the right value.

+=                  Adds the value of the right operand to the value of the left operand.

-=                  Subtracts the value of the right operand from the value of the left operand.

x=                  Multiplies the value of the left operand with the value of the right operand.

>>                  Shifts the left operand right by the number of bits specified by the right operand.

<<                  Shifts the left operand left by the number of bits specified by the right operand.

~                   Performs a 1s complement of the operator. This is a unary operator.

   
    
    
  








Related examples in the same category

1.Perl statements end with a semicolon (;)
2.Perl Statements
3.Operator Precedence
4.Operator associativity.
5.Operator precedence.
6.Operators demo: Combined Assignment Operators
7.Operators demo: Comparison Operators
8.Operators demo: Logical Operators
9.Operators demo: String Operators
10.Perl Flow Control Commands
11.Perl Flow Control in Brief
12.Perl offers many types of operators
13.Precedence and Associativity
14.The startup line tells the shell where Perl is located.
15.Statements, Whitespace, and Linebreaks
16.Ending modifiers