Rockwell-automation 1771-DB BASIC MODULE Manual de usuario Pagina 118

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 394
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 117
Chapter
Expressions, Variables and Operators
9
9 -8
.OR.
Use the bitwise .OR. operator to perform a bitwise OR on two expressions.
The .OR. operator compares the bits of the two expressions and sets the bit
to 1 (true) if either of bits being compared is set to 1 (true).
>PRINT
1.OR.4
Result: 5
This example performs a bitwise OR on the integers 1 and 4 and prints the
result. First, BASIC converts 1 and 4 to binary:
1 = 0001
4 = 0100
Then the BASIC module compares each digit of the binary number to
determine if either of the bits is set to a 1. For example, the last digit of the
first operand is 1 (true) and the last digit of the second operand is 0 (false)
so the resulting bit is set to 1.
0001
0100
0101
The BASIC module converts the resulting binary number back into an
integer and prints the result
0101 = 5
.XOR.
Use the bitwise .XOR. operator to perform an exclusive OR on two
expressions. The .XOR. compares the two bits of the expressions and sets
the bit to 1 (true) only if one of the bits in the comparison is set to 1 (true).
>PRINT
7.XOR.6
Result: 1
This example performs a bitwise XOR on the integers 7 and 6 and prints
the result. First, BASIC converts 7 and 6 to binary:
7 = 0111
6 = 0110
Then the BASIC module compares each digit of the binary number to
determine if only one of the bits is set to a 1. For example, the second digit
of first operand is 1 (true) and the second digit of the second operand is 1
(true) so the resulting bit is set to 0 (false) because both digits are set to 1.
0111
0110
0001
The BASIC module converts the resulting binary number back into an
integer and prints the result.
0001 = 1
Vista de pagina 117
1 2 ... 113 114 115 116 117 118 119 120 121 122 123 ... 393 394

Comentarios a estos manuales

Sin comentarios