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
Variables may be constants, variables or expressions. 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.
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial1_Baud = 9600
Declare Hrsout1_Pin = PORTB.14
Dim MyWord1 as Word
Dim MyWord2 as Word
PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX) ' Make Pin RB14 U1TX
MyWord1 = $FDE8
MyWord2 = MyWord1 ** MyWord1 ' Multiply $FDE8 by itself
HrsoutLn Hex MyWord2 ' Return 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 Positron16 compiler.
