Positron Compiler Documentation

Add '+'

Positron8 · Revision 4.0.6.5 · PDF page 80

Assignment Variable = Variable + Variable

Adds variables and/or constants, returning an unsigned or signed 8, 16, 24, 32-bit or floating point result.

Variable can be a constant, variable or expression. Assignment Variable can be any valid variable type.

Addition works exactly as you would expect with signed and unsigned integers as well as floating point.

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 = 1575
Dim wMyVar2 as Word = 976

wMyVar1 = wMyVar1 + wMyVar2    ' Add the numbers.
HRsoutLn Dec wMyVar1           ' Display the result
  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 addition
  Dim wMyVar1 as Word
  Dim dMyVar2 as Dword

  wMyVar1 = 1575
  dMyVar2 = 9763647
  dMyVar2 = dMyVar2 + wMyVar1    ' Add the numbers.
  HRsoutLn Dec wMyVar2           ' Display the result
View original PDF page 80Open page in PDFOriginal PDF page 80