User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
If number is converted from less complex to more complex data type, upper byte
is filled with zeros;
If number is converted from more complex to less complex data type, data is sim-
ply truncated (upper bytes are lost).
Example for unsigned and logical operators :
dim teA as byte
dim Bb as word
main:
Bb = $F0F0
teA = $aa
Bb = Bb and teA
' Bb becomes $00a0
end.
In this case, A is treated as a word with upper byte equal to 0 prior to the opera-
tion.
If number is converted from less complex data type to more complex, upper bytes
are filled with ones if sign bit is 1 (number is negative); upper bytes are filled with
zeros if sign bit is 0 (number is positive).
If number is converted from more complex data type to less complex, data is sim-
ply truncated (upper bytes are lost).
dim Sa as short
dim Sbb as integer
main:
Sbb = $70FF
Sa = -12
Sbb = Sbb and Sa
' Bb becomes $70f4
end.
In this case, Sa is treated as an integer with the upper byte equal to $FF (this in
fact is sign extending of short to integer) prior to the operation.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
81
page
Unsigned and
Conversion
Signed and
Conversion