DIAdem Help

Content Type
Programming Language
Current manual
Table of Contents

Function: AndB

Function: AndB

Calculates the number that results from the identical bits of two numbers. The AndB function converts the decimal numbers into binary numbers, determines the identical bits, and reconverts this binary number into a decimal number.

ReturnValue = AndB(Value1, Value2)

Input Parameters

Value1 Specifies a numeric value, a variable, or a data channel.
Value2 Specifies a numeric value, a variable, or a data channel.
Note  If you specify numbers with decimal places for the parameters Value1 and Value2, DIAdem rounds the numbers to integers.

Return Parameters

ReturnValueReturns integer values. If two numbers contain no identical bits, the function returns the result 0. If the input value is NoValue, the AndB function returns the value NoValue.

Examples

The following example calculates the identical bits of the two decimal numbers 10 and 12 and saves the corresponding decimal number.

VBScriptPython

 

Dim intMyResult
intMyResult = AndB(10,12)   'intMyResult = 8

The following example calculates the identical bits of the values in each line of two data channels, and saves the decimal numbers in the new data channel Group2/Result.

VBScriptPython

 

Call Calculate ("Ch(""Group2/Result"")= AndB (Ch(""Group1/Input""),Ch(""Group1/Reference""))")
Note  You must use the Calculate command in scripts to calculate data channels with formulas. Compute the data channels according to the syntax in the Calculator. Refer to the procedures Executing Channel Calculations in the Calculator and Assigning a Value to a Variable in the Calculator for more information about the Calculator.
Note  You also can use VBS function And to calculate the identical bits of two numbers.
The first and the second physical quantity must be the same. The physical input quantities and the result quantities are the same.
The Input and Result Quantities for Quantity-Based Calculations page contains an overview of the input quantities and result quantities of all functions. Refer to the Help page Calculating Quantity-Based and Non-Quantity-Based in DIAdem for the conditions and rules for quantity-based calculations.

Related Functions

Function: ClrB | Function: GetB | Function: NotB | Function: OrB | Function: SetB | Function: ShL | Function: ShR | Function: XOrB | Variable: ApplicationLegacyBinaryOperations

Was this information helpful?