MikroElektronika PIC Microcontrollers PIC16 Uživatelský manuál Strana 91

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 172
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 90
Comparing variables and constants always produces the correct results regardless
of the operands' type.
if A > B then ...
if A > 47 then ...
if A + B > A ...
First, compiler evaluates the expression on the left. During the run-time, result is
stored in a variable of type that matches the largest data type in the expression. In
this case it is byte, as variables A and B are both bytes.
This is correct if the value does not exceed range 0..255, that is, if A + B is less
then 255.
Let's assume Aa is of word type :
if Aa + B > A ...
First, compiler evaluates the expression on the left. The result value is treated as
type that matches the largest data type in the expression. Since Aa is word and B
is byte, our result will be treated as word type.
This is correct if the value does not exceed range 0..65535, that is, if A + B is less
then 65535.
' if tC is less than zero, tC = -tC :
if tC < 0 then
tC = -tC
end if
' Stay in loop while C is not equal to variable
' compare_match; increment C in every cycle:
while tC <> compare_match
tC = tC + 1
wend
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
86
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
page
Examples
Zobrazit stránku 90
1 2 ... 86 87 88 89 90 91 92 93 94 95 96 ... 171 172

Komentáře k této Příručce

Žádné komentáře