Positron Compiler Documentation

Divide '/'

Positron8 · Revision 4.0.6.5 · PDF page 85

Assignment Variable = Variable / Variable

Divides 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.

The Divide operator works exactly as you would expect with signed or unsigned integers from - 2147483648 to +2147483647 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
Dim wMyVar2 as Word

wMyVar1 = 1000
wMyVar2 = 5
wMyVar1 = wMyVar1 / wMyVar2              ' Divide the numbers.
HRsoutLn Dec wMyVar1                     ' Display the result (200).
' 32-bit division
  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 dMyVar2 as Dword

  wMyVar1 = 100
  dMyVar2 = 10000
  dMyVar2 = dMyVar2 / wMyVar1              ' Divide the numbers.
  HRsoutLn Dec dMyVar2                     ' Display the result
View original PDF page 85Open page in PDFOriginal PDF page 85