spec

Software for Diffraction

2.3.16. - Operators



The following tables summarize the operators available in spec. (Almost all these operators work the same as in the C language, so a C-language reference manual could be consulted to provide more detailed information on the use of unfamiliar operators.) Operators that require integral operands use the integer part of nonintegral operands. The precedence rules give the evaluation order when multiple operators appear in the same expression.

spec stores number values as double precision floating point, which only has 52 bits for the signifcand. The bitwise operators (<<, >>, &, ^, |, <<=, >>=, &=, ^=, |=) will mask the operands to 52 bits. The result of the operation will be no more than 52 bits. The bit-not operator (~) will mask the result to the low 52 bits. The modulus operators (% and %=) will convert the operands to 64 bits, perform the operation using 64-bit integer arithmetic, then convert the result to a double for the return value.