Multiply High '**'
Syntax
Assignment Variable = Variable ** Variable
Overview
Multiplies 8 or 16-bit unsigned variables and/or constants, returning the high 16 bits of the result. For compatibility with the old BASIC Stamp modules.
Operands
Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
When multiplying two 16-bit values, the result can be as large as 32 bits. Since the largest variable supported by the compiler is 16-bits, the highest 16 bits of a 32-bit multiplication result are normally lost. The ** (double-star) operand produces these upper 16 bits.
For example, suppose 65000 ($FDE8) is multiplied 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.
Example
Device = 18F26K40 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' Set the Baud rate for HRsoutLn
Dim wMyVar1 as Word
Dim wMyVar2 as Word
wMyVar1 = $FDE8
wMyVar2 = wMyVar1 ** wMyVar1 ' Multiply $FDE8 by itself
HRsoutLn Hex wMyVar2 ' Display the high 16 bits.
Note.
This operator enables compatibility with BASIC Stamp code, and melab's compiler code, but is rather obsolete considering the 32-bit capabilities of the Positron8 compiler.
