Campbell-scientific CR3000 Micrologger Manual de usuario Pagina 496

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 590
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 495
Appendix A. CRBasic Programming Instructions
496
+
Add
-
Subtract
=
Equal to
<>
Not equal to
>
Greater than
<
Less than
>=
Greater than or
equal to
<=
Less than or
equal to
A.6.3 Bitwise Operators
Bitwise shift operators (<< and >>) allow the program to manipulate the positions
of patterns of bits within an integer (CRBasic Long type). Here are some example
expressions and the expected results:
&B00000001 << 1 produces &B00000010 (decimal 2)
&B00000010 << 1 produces &B00000100 (decimal 4)
&B11000011 << 1 produces &B10000110 (decimal 134)
&B00000011 << 2 produces &B00001100 (decimal 12)
&B00001100 >> 2 produces &B00000011 (decimal 3)
The result of these operators is the value of the left hand operand with all of its
bits moved by the specified number of positions. The resulting "holes" are filled
with zeroes.
Consider a sensor or protocol that produces an integer value that is a composite of
various "packed" fields. This approach is quite common to conserve bandwidth
and/or storage space. Consider the following example of an eight-byte value:
bits 7-6: value_1
bits 5-4: value_2
bits 3-0: value_3
Code to extract these values is shown in CRBasic example Using Bit-Shift
Operators
(p. 497).
With unsigned integers, shifting left is equivalent to multiplying by two. Shifting
right is equivalent to dividing by two.
<<
Bitwiseleftshift
Syntax
Variable = Numeric Expression >> Amount
Vista de pagina 495
1 2 ... 491 492 493 494 495 496 497 498 499 500 501 ... 589 590

Comentarios a estos manuales

Sin comentarios