Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 241
2
//
Returns the remainder left after dividing one value by another. Some
division problems don’t have a whole-number result; they return a
whole number and a fraction. For example, 1000/6 = 166.667. Integer
math doesn’t allow the fractional portion of the result, so 1000/6 = 166.
However, 166 is an approximate answer, because 166*6 = 996. The di-
vision operation left a remainder of 4. The // (double-slash) returns
the remainder of a given division operation. Naturally, numbers that
divide evenly, such as 1000/5, produce a remainder of 0. Example:
w1 = 1000
w2 = 6
w1 = w1 // w2 ' Get remainder of w1 / w2.
debug dec ? w1 ' Show the result (4).
*
Multiplies variables and/or constants, returning the low 16 bits of the
result. Works exactly as you would expect with unsigned integers from
0 to 65535. If the result of multiplication is larger than 65535, the excess
bits will be lost. Multiplication of signed variables will be correct in
both number and sign, provided that the result is in the range -32767
to +32767.
w1 = 1000
w2 = -19
w1 = w1 * w2 ' Multiply w1 by w2.
debug sdec ? w1 ' Show the result (-19000).
**
Multiplies variables and/or constants, returning the high 16 bits of the
result. When you multiply two 16-bit values, the result can be as large
as 32 bits. Since the largest variable supported by PBASIC2 is 16 bits,
the highest 16 bits of a 32-bit multiplication result are normally lost.
The ** (double-star) instruction gives you these upper 16 bits. For
example, suppose you multiply 65000 ($FDE8) by itself. The result is
4,225,000,000 or $FBD46240. The * (star, or normal multiplication)
-instruction would return the lower 16 bits, $6240. The ** instruction
returns $FBD4.