You are here: PBASIC Language Reference > PBASIC Operators > Unary Operators

Unary Operators

 

Unary operators work with a single argument. Click on any operator in the list below for details and examples.

(See also: Binary Operators and Operator Precedence.)

Notes about the 16-bit workspace

Many of the operator descriptions will say something like "computes (some function) of a 16-bit number." This does not mean that the operator does not work on smaller byte or nibble values, but rather that the computation is done in a 16-bit workspace. If the value is smaller than 16 bits, the BASIC Stamp pads it with leading 0s to make a 16-bit value. If the 16-bit result of a calculation is to be packed into a smaller variable, the higher-order bits are discarded (truncated).

ABS   (Returns Absolute Value)
-   (Negate)
~   (Invert Bits)
DCD   (2n power Decoder)
NCD   (Priority Encoder of 16-bit Value)
SIN   (Returns signed Sine of Angle)
COS   (Returns signed Cosine of Angle)
SQR   (Returns Square Root of Value)
NOT   (Logical NOT)

 

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012