Multiply '*'
Positron16 · Revision 1.1.3.5 · PDF page 78
Syntax
Assignment Variable = Variable * Variable
Overview
Multiplies variables and/or constants, returning an unsigned or signed 8, 16, 32-bit or floating point result.
Operands
Variables may be constants, variables or expressions. Assignment Variable can be any valid variable type.
Multiply works exactly as you would expect with signed or unsigned integers from -2147483648 to +2147483647, or 0 to 4294967295, as well as floating point.
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 = 1000
MyWord2 = 19
MyWord1 = MyWord 1 * MyWord2 ' Multiply MyWord1 by MyWrd2.
HrsoutLn Dec MyWord1 ' Display the result
' 32-bit multiplication
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 MyWord as Word
Dim MyDword as Dword
PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX) ' Make Pin RB14 U1TX
MyWord = 100
MyDword = 10000
MyDword = MyDword * MyWord ' Multiply the numbers.
HrsoutLn Dec MyDword ' Display the result
