User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
You cannot mix signed and unsigned data types in expressions with arithmetic or
logical operators. You can use explicit conversion though.
dim Sa as short
dim A as byte
dim Bb as word
dim Sbb as integer
dim Scccc as longint
...
A = A + Sa
' compiler will report an error
A = A and Sa
' compiler will report an error
' But you can freely mix byte with word..
Bb = Bb + (A * A)
' ..and short with integer and longint
Scccc = Sbb * Sa + Scccc
You can assign signed to unsigned or vice versa only using the explicit conversion.
Sa = short(A)
' this can be done
Sa = A
' this can't be done,
' compiler will report an error
Relation operators can freely be used even when mixing signed and unsigned data.
For example:
if Sa > B then
Sa = 0
end if
Comparing variable or constant to variable or constant will always produce correct
results.
Comparing expressions requires a little more attention. For more information refer
to the chapter Implicit Conversion and Relation Operators.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
45
page
Note