beautypg.com

A.6.4 compound-assignment operators, A.6.5 logical operators, Table 120. compound-assignment operators – Campbell Scientific CR3000 Micrologger User Manual

Page 497: Crbasic example 71. using bit-shift operators

background image

Appendix A. CRBasic Programming Instructions

497

 

>> 
Bitwise right shift 

Syntax 

Variable = Numeric Expression >> Amount

& 

Bitwise AND assignment ‐‐ Performs a bitwise AND of a variable with an 
expression and assigns the result back to the variable. 

A.6.4 Compound-assignment operators

Table 120. Compound-Assignment Operators

Symbo

l

Name Function

^=

Exponent
assignment

Raises the value of a variable to the power of an expression and
assigns the result back to the variable.

*=

Multiplication
assignment

Multiplies the value of a variable by the value of an expression and
assigns the result to the variable.

+=

Addition
assignment

Adds the value of an expression to the value of a variable and
assigns the result to the variable. Also concatenates a String
expression to a String variable and assigns the result to the
variable.

-=

Subtraction
assignment

Subtracts the value of an expression from the value of a variable
and assigns the result to the variable.

/=

Division
assignment

Divides the value of a variable by the value of an expression and
assigns the result to the variable.

\=

Division integer
assignment

Divides the value of a variable by the value of an expression and
assigns the integer result to the variable.

 

CRBasic Example 71. Using Bit‐Shift Operators 

Dim

input_val

As Long

Dim

value_1

As Long

Dim

value_2

As Long

Dim

value_3

As Long

'read input_val somehow

value_1 = (input_val AND &B11000000) >> 6
value_2 = (input_val AND &B00110000) >> 4

'note that value_3 does not need to be shifted

value_3 = (input_val AND &B00001111)

 

A.6.5 Logical Operators

AND 
Performs a logical conjunction on two expressions. 

Syntax 

result = expr1 AND expr2