Unary Operators

Unary operators are operators that take exactly one argument.

Unary Arithmetic Operator

Operator - can be used as a prefix unary operator to change sign of a signed value. Unary prefix operator + can be used also, but it doesn’t affect data.

For example:

b := -a;

Unary Bitwise Operator

The result of the not (bitwise negation) operator is the bitwise complement of the operand. In the binary representation of the result, every bit has the opposite value of the same bit in the binary representation of the operand.

Operator Operation
not bitwise complement (unary); inverts each bit
Example:
not 0x1234              ' equals 0xEDCB

Address and Indirection Operator

In the mikroPascal PRO for PIC, address of an object in memory can be obtained by means of an unary operator @. To reach the pointed object, we use an indirection operator ^ on a pointer. See Pointers section for more details.

Operator Operation
^ accesses a value indirectly, through a pointer; result is the value at the address to which operand points
@ constructs a pointer to its operand

See Pointers for more details on this subject

  Note : Besides these, sizeof and explicit conversion unary operators are supported also.
Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code