home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
swCHIP 1991 January
/
swCHIP_95-1.bin
/
demo
/
wit4711
/
lib
/
help
/
point
/
calc.
/
calc.bin
Wrap
Text File
|
1995-12-09
|
2KB
|
62 lines
OPERATOR
calc --- perform alu operations on two input objects
DESCRIPTION
The calc operator performs alu type operations on two input objects. The input
objects may be any combination of primitive objects or vectors of primitives.
The output is casted to integer or double following the same casting rules
as in C. The operation to be performed is specified by a C style
mathematical expression, entered using the expression parameter. The userConstant
field allows the user to specify a constant of type double for use within
the specified expression.
There are five case insensitive variables available for access by the user:
variables
A (or a) - top input object
B (or b) - bottom input object
X (or x) - current vector column value.
Y (or y) - current vector row value.
K (or k) - the value specified in userConstant
The available operators (ordered by precedence from highest to lowest) are
listed below and may be used to form the expression:
binary operators
** - exponentiation
* / % - multiplication, division, modulus
+ - - addition, subtraction
<< >> - bit shift left, bit shift right
< > >= <= == != - boolean comparisons
& | ^ - bitwise and, or, xor.
&& || - boolean conjunction, boolean disjunction
unary operators
- ! - unary negation, boolean not
abs() sqrt() exp() - absolute value, square root, e**x
sin() cos() tan() - trigonometric functions
asin() acos() atan() - inverse trigonometric functions
log() log10() log2() - natural log, log base 10, log base 2
floor() ceil() rint() - floor, ceiling and rounding functions.
precedence
( ) - parentheses can be used to alter precedence
conditional operator
(comparison) ? (result if true) : (result if false)
Note that all calculations are performed using double precision except for the
modulus and bit operations, which have their operands cast to integer first.
To perform integer division, rather than floating point division, use
floor(A/B) rather than A/B.