Multiply '*'
Positron8 · Revision 4.0.6.5 · PDF page 82
Syntax
Assignment Variable = Variable * Variable
Overview
Multiplies variables and/or constants, returning an unsigned or signed 8, 16, 24, 32-bit or floating point result.
Operands
Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
Multiply works exactly as you would expect with signed or unsigned integers from -2147483648 to +2147483647 as well as floating point. If the result of multiplication is larger than 2147483647 when using 32-bit variables, the excess bit will be lost.
Example 1
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 = 1000 ' Create a variable and assign a value to it
Dim wMyVar2 as Word = 19 ' Create a variable and assign a value to it
wMyVar1 = wMyVar1 * wMyVar2 ' Multiply wMyVar1 by wMyVar2
HRsoutLn Dec wMyVar1 ' Display the result
Example 2
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
' 32-bit multiplication
Dim wMyVar1 as Word
Dim dMyVar2 as Dword
wMyVar1 = 100
dMyVar2 = 10000
dMyVar2 = dMyVar2 * wMyVar1 ' Multiply the numbers
HRsoutLn Dec dMyVar2 ' Display the result
