Propeller Manual

Table Of Contents
Operators – Spin Language Reference
Divide ‘/’, ‘/=
Divide can be used in both variable and constant expressions. When used with variable
expressions or integer constant expressions, it divides one value by another and returns the
32-bit integer result. When used with floating-point constant expressions, it divides one
value by another and returns the 32-bit single-precision floating-point result. Example:
X := Y / 4
Divide has an assignment form, /=, that uses the variable to its left as both the first operand
and the result destination. For example,
X /= 20 'Short form of X := X / 20
Here, the value of X is divided by 20 and the integer result is stored back in X. The
assignment form of Divide may also be used within expressions for intermediate results; see
Intermediate Assignments, page 147.
Modulus ‘
//’, ‘//=
Modulus can be used in both variable and integer constant expressions, but not in floating-
point constant expressions. Modulus divides one value by another and returns the 32-bit
integer remainder. Example:
X := Y // 4
If Y started out as 5 then Y // 4 equals 1, meaning the division of 5 by 4 results in a real
number whose fractional component equals ¼, or .25.
Modulus has an assignment form,
//=, that uses the variable to its left as both the first
operand and the result destination. For example,
X //= 20 'Short form of X := X // 20
Here, the value of X is divided by 20 and the 32-bit integer remainder is stored back in X. The
assignment form of Modulus may also be used within expressions for intermediate results;
see Intermediate Assignments, page 147.
Page 154 · Propeller Manual v1.1