11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler4 - Math operatorsThe <strong>PICBASIC</strong> <strong>PLUS</strong> Compiler performs all math operations in full hierarchal order.Which means that there is precedence to the operators. For example, multiplies anddivides are performed before adds and subtracts. To ensure the operations are carriedout in the correct order use parenthesis to group the operations: -A = (( B – C ) * ( D + E )) / FAll math operations are unsigned and performed with 16-bit precision.The operators supported are: -+ Addition- Subtraction* Multiplication** Top 16 Bits of Multiplication*/ Middle 16 Bits of Multiplication/ Division// Remainder (Modulus)> Shift Right& Bitwise AND| Bitwise OR^ Bitwise XOR4.1. Addition ‘+’.The Addition operator (+) adds variables and/or constants, returning a 16-bit result.Works exactly as you would expect with unsigned integers from 0 to 65535. If the resultof addition is larger than 65535, the carry bit will be lost.DIM Value1 as WORDDIM Value2 as WORDValue1 = 1575Value2 = 976Value1 = Value1 + Value2PRINT @Value1' Add the numbers.' Display the result4.2. Subtraction ‘-‘.The Subtraction operator (-) subtracts variables and/or constants, returning a 16-bit result.Works exactly as you would expect with unsigned integers from 0 to 65535.DIM Value1 as WORDDIM Value2 as WORDValue1 = 1000Value2 = 999Value1 = Value1 - Value2PRINT @Value1' Subtract the numbers.' Display the result15Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!