Function: ShL
- 更新时间2023-02-21
- 阅读时长3分钟
Function: ShL
Shifts the bits in the binary representation of a decimal number to the left by a specific number of places. The ShL function converts the decimal number into a binary number, inserts on the right as many zeros as you specify, and reconverts the binary number into a decimal number.
ReturnValue = ShL(Value, Digits)
Input Parameters
| Value | Specifies a numeric value, a variable, or a data channel. |
| Digits | Specifies a numeric value, a variable, or a data channel for the number of places you want to shift. Value range 0 to 31 |
| Note If you enter numbers with decimal places for the parameters Value and Digits, DIAdem rounds off the numbers to integers. From DIAdem 2014, the function no longer calculates the sum of the Digits input parameter. |
Return Parameters
| ReturnValue | Returns integer values. If the input value is NoValue, the ShLB function returns the value NoValue. If the input parameter Digits is outside the value range, the function returns the value 0. |
Examples
The following example adds two zeros to the binary representation of the decimal number 13 and saves the new decimal number.
| VBScript | Python |
Dim intMyResult intMyResult = ShL(13,2) 'intMyResult = 52
The following example adds bits on the right of the binary representation of the values in the Group1/Input data channel. The number of places added is specified in the Group1/Reference data channel. The example saves the new decimal numbers in the data channel Group2/Result.
| VBScript | Python |
Call Calculate ("Ch(""Group2/Result"")= ShL (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. |
![]() |
The first physical input quantity is arbitrary. The second input quantity must be dimensionless. The first physical input quantity and the result quantity 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: AndB | Function: ClrB | Function: GetB | Function: NotB | Function: OrB | Function: SetB | Function: ShR | Function: XOrB | Variable: ApplicationLegacyBinaryOperations
