Unary Operators (Cross Ref > Operators)
An operation with only one operand (a single input). Common unary operators include + plus, - minus, and bitwise not. Some operators can function as both unary and binary operators. For example, + and - operators can serve as either. Languages FocusWhat unary operators are supported in additoin to the standard plus, minus, and bitwise not.
Access VBA:
An operation with only one operand (a single input) such as +, -, and Not.
More Info
|
ASP Classic:
An operation with only one operand (a single input) such as +, -, and Not.
More Info
|
C#:
An operation with only one operand (a single input). The following are the C# unary operators: + , - , ! , ~ , ++ , -- , true , or false.
More Info
|
C++:
An operation with only one operand (a single input) such as ++X and --Y.
More Info / Comment
About Unary Operator An operation with only one operand (a single input).
More Info
More Info
|
Corel Paradox:
The ObjectPAL unary operators are:
More Info / Comment
More Info
|
Delphi:
An operation with only one operand (a single input). In Object Pascal, a unary operator has the highest precedence and always precedes its operand (for example, -B), except for the ^ pointer operator, which follows its operand (for example, P^). In addition to the obvious +, -, and Not operators, Delphi also offers:
^ |
Pointer |
@ |
returns the address of a variable, function, procedure, or method; a pointer to its operand. |
inc() |
Increment |
dec() |
Decrement |
The TYPE operator is also a unary operator and is valuated at compile time. The TYPE operator returns the size in bytes of the operand,
More Info / Comment
More Info
|
Delphi Prism:
The obvious Prism unary operators are +, -, and Not.
+ |
Plus |
- |
Minus |
Not |
Bitwise Not |
Inc() |
Increment |
Dec() |
Decrement |
Syntax Example:var i: Integer := 1; Inc(i); MessageBox.Show("" + i); //Displays 2
|
Inc() and Dec()
Inc will increment an ordinal or float named variable by 1 or a value you specify. Dec will decrement a named variable by 1 or a value you specify.
Examples:var i: Integer := 1; Inc(i); //Increment by 1 (default). Inc(i, 3); //Increment by 3. Dec(i); //Decrement by 1 (default). Dec(i, 3); //Decrement by 3. //The following displays 3.65. var i: Double := 1; Inc(i, 2.65); //Increment by 2.65.
MessageBox.Show("" + i);
More Info
|
Java:
An operation with only one operand (a single input). The Java unary operators are ++, --, +, -, ~, and !.
- + Indicates positive value (numbers are positive without this)
- - Negates an expression
- ++ Increment operator by 1
- -- Decrement operator by 1
- ! Logical complement operator (inverts the value of a boolean)
- ~ Bitwise inversion operator (works on integral data types)
More Info / Comment
More Info
|
JavaScript:
An operation with only one operand (a single input). JavaScript unary operators include ++ and --. They can be used either before or after a variable as in: a++, b--, and ++a, and --b.
Examples: iCounter++; iCounter--; ++iCounter; --iCounter;
Syntax Example:var iCounter=0; for (iCounter=0;iCounter<=5;iCounter++) { document.write("Count is " + iCounter + "<br>"); }
|
Working Example<html> <body> <script language=JavaScript> <!-- var iCounter=0; for (iCounter=0;iCounter<=5;iCounter++) { document.write("Count is " + iCounter + "<br>"); } //--> </script> </body> </html>
More Info
|
Perl:
An operation with only one operand (a single input). The following are the Perl unary operators: !, -, ~, +, \, &, and *.
- ! performs logical negation which is "not"
- - performs arithmetic negation if the operand is numeric.
- ~ performs bitwise negation, that is 1's complement.
- + has no semantic effect whatsoever, even on strings.
- \ creates a reference to whatsoever follows.
- & Address of operator.
- * Dereference address operator.
More Info
|
PHP:
A unary operator operates on only one value.
PHP Examples:
- ! negation operator
- ++ increment operator
- -- decrement operator
More Info
|
VB Classic:
An operation with only one operand (a single input) such as +, -, and Not.
More Info
|
VB.Net:
An operation with only one operand (a single input). A unary operator method can return any type but takes only one parameter, which must be the type of the containing class. In addition to the obvious +, -, and Not operators, VB.Net also offers:
More Info
|
|