OPERATOR: arithmetic:
+ - * / div % << >>
>>> & | ^ ++ -- ~
The arithmetic operators are
used to perform basic, complex, and unary mathematic operations. There
are fifteen arithmetic operators.
+
The + is the arithmetic addition operator. This operator
is used to add floating-point and/or integer numbers. It can also be used
as a string operator to concatenate (join) strings.
-
The - is the arithmetic subtraction operator. This operator
is used to subtract floating-point and/or integer numbers.
*
The * is the arithmetic multiplication operator. This operator
is used to multiply floating-point and/or integer numbers.
/
The / is the arithmetic floating-point division operator.
This operator is used to divide floating-point numbers.
div
The div is the arithmetic integer division operator. This
operator is used to divide integer numbers. The results are always rounded
down (towards zero).
%
The % is the arithmetic modulus operator. This operator
is used to find the remainder in a modulus operation.
<<
The << is the arithmetic bitwise left shift operator.
This operator shifts the digits of the binary representation of the first
operand to the left by the number of places specified by the second operand.
The spaces created to the right are filled in by zeros, and any digits
falling off the left are discarded.
>>
The >> is the arithmetic bitwise right shift operator.
This operator shifts the digits of the binary representation of the first
operand to the right by the number of places specified by the second operand,
discarding any shifted off to the right. The copies of the leftmost bit
are added on from the left, thereby preserving the sign of the number.
>>>
The >>> is the arithmetic bitwise zero fill right shift
operator. This operator shifts the binary representation of the first
operand to the right by the number of places specified by the second operand.
Bits shifted off to the right are discarded and zeroes are added on to
the left.
&
The & is the arithmetic bitwise AND operator. This operator
returns a 1 for each bit position where the corresponding bits of both
its operands are 1.
|
The | is the arithmetic bitwise OR operator. This operator
returns a 1 for each bit position where one or both of the corresponding
bits of its operands is a 1.
^
The ^ is the arithmetic bitwise XOR operator. This operator
returns a 1 for each position where one (not both) of the corresponding
bits of its operands is a 1.
++
The ++ is the arithmetic pre-or-post increment operator.
This operator is used to pre- or post-increment (increase) the value of
an integer by 1.
--
The -- is the arithmetic pre-or-post decrement operator.
This operator is used to pre- or post-decrement (decrease) the value of
an integer by 1.
~
The ~ is the arithmetic bitwise NOT operator. This operator
is used to convert each bit of its operand to its opposite (0 to 1, 1
to 0).
Code fragment:
...
var result = (A + B +
((C*D -
E)/F) -
G);
var result = int1 div 95;
var result = A % B;
...
var result = A << B;
var result = A >> B;
var result = A >>> B;
...
var result = A & B;
var result = A | B;
var result = A ^ B;
...
count = count++;
count = ++count;
count = count--;
count = --count;
...
var result = ~C;
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
|