04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix A. CRBasic Programming Instructions<br />

The result of these operators is the value of the left hand operand with all of its<br />

bits moved by the specified number of positions. The resulting "holes" are filled<br />

with zeroes.<br />

Consider a sensor or protocol that produces an integer value that is a composite of<br />

various "packed" fields. This approach is quite common to conserve bandwidth<br />

and/or storage space. Consider the following example of an eight-byte value:<br />

• bits 7-6: value_1<br />

• bits 5-4: value_2<br />

• bits 3-0: value_3<br />

Code to extract these values is shown in CRBasic example Using Bit-Shift<br />

Operators (p. 494).<br />

With unsigned integers, shifting left is equivalent to multiplying by two. Shifting<br />

right is equivalent to dividing by two.<br />

> Amount<br />

>><br />

Bitwise right shift<br />

Syntax<br />

Variable = Numeric Expression >> Amount<br />

&<br />

Bitwise AND assignment ‐‐ Performs a bitwise AND of a variable with an<br />

expression and assigns the result back to the variable.<br />

A.6.4 Compound-assignment operators<br />

Table 117. Compound-Assignment Operators<br />

Symbo<br />

l<br />

^=<br />

*=<br />

+=<br />

-=<br />

/=<br />

\=<br />

Name<br />

Exponent<br />

assignment<br />

Multiplication<br />

assignment<br />

Addition<br />

assignment<br />

Subtraction<br />

assignment<br />

Division<br />

assignment<br />

Division integer<br />

assignment<br />

Function<br />

Raises the value of a variable to the power of an expression and<br />

assigns the result back to the variable.<br />

Multiplies the value of a variable by the value of an expression and<br />

assigns the result to the variable.<br />

Adds the value of an expression to the value of a variable and<br />

assigns the result to the variable. Also concatenates a String<br />

expression to a String variable and assigns the result to the<br />

variable.<br />

Subtracts the value of an expression from the value of a variable<br />

and assigns the result to the variable.<br />

Divides the value of a variable by the value of an expression and<br />

assigns the result to the variable.<br />

Divides the value of a variable by the value of an expression and<br />

assigns the integer result to the variable.<br />

494

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!